- loading
OleContainer1. DestroyObject;
OleContainer1. CreateObjectFromFile (' D: \ a. d. oc, False);
- the print preview
OleContainer1. OleObject. Application. The ActiveDocument. PrintPreview;
- an error:
Project Project1. Exe raised exception class EIntfCastError with message 'Interface not supported'. Process stopped. Use Step or Run to continue.
- check the OleObject when debugging, no value, abnormal directly the
CodePudding user response:
Procedure TForm1. Button1Click (Sender: TObject);
The begin
OleContainer1. DestroyObject;
OleContainer1. CreateObjectFromFile (' D: \ a. d. oc, false);
OleContainer1. DoVerb (ovShow);
OleContainer1. Run;
OleContainer1. OleObject. Application. The ActiveDocument. PrintOut;
end;
CodePudding user response:
Thanks to 1st floor, can print, but there is a new problem: every time after loading at the top of the window shows a Word toolbar, and OleContainer into edit mode, how to remove the toolbar and edit mode?CodePudding user response:
Procedure TForm1. Button1Click (Sender: TObject);
The begin
OleContainer1. DestroyObject;
OleContainer1. CreateObjectFromFile (' D: \ a. d. oc, false);
OleContainer1. DoVerb (ovShow);
OleContainer1. Run;
OleContainer1. OleObject. Application. The ActiveDocument. Protect (2);
OleContainer1.OleObject.application.Com mandBars [' Standard ']. Visible:=false;
OleContainer1.OleObject.application.Com mandBars [' Formatting]. Visible:=false;
OleContainer1.OleObject.application.Com mandBars [' Reviewing ']. Visible:=false;
OleContainer1. OleObject. Application. The ActiveDocument. PrintOut;
end;