使用了如下方法,但不行:
--加載
OleContainer1.DestroyObject;
OleContainer1.CreateObjectFromFile(‘D:\A.doc’, False);
--列印預覽
OleContainer1.OleObject.Application.ActiveDocument.PrintPreview;
--報錯:
Project Project1.exe raised exception class EIntfCastError with message 'Interface not supported'. Process stopped. Use Step or Run to continue.
--除錯時查看OleObject,沒有值,直接例外了
uj5u.com熱心網友回復:
procedure TForm1.Button1Click(Sender: TObject);
begin
OleContainer1.DestroyObject;
OleContainer1.CreateObjectFromFile('D:\A.doc', false);
OleContainer1.DoVerb(ovShow);
OleContainer1.Run;
OleContainer1.OleObject.Application.ActiveDocument.PrintOut;
end;
uj5u.com熱心網友回復:
感謝1樓,能正常列印,但有個新問題:每次加載后都在視窗頂端顯示了一個Word工具條,并且OleContainer進入了編輯模式,怎么去掉工具條和編輯模式?uj5u.com熱心網友回復:
procedure TForm1.Button1Click(Sender: TObject);
begin
OleContainer1.DestroyObject;
OleContainer1.CreateObjectFromFile('D:\A.doc', false);
OleContainer1.DoVerb(ovShow);
OleContainer1.Run;
OleContainer1.OleObject.Application.ActiveDocument.Protect(2);
OleContainer1.OleObject.application.CommandBars['Standard'].Visible:=false;
OleContainer1.OleObject.application.CommandBars['Formatting'].Visible:=false;
OleContainer1.OleObject.application.CommandBars['Reviewing'].Visible:=false;
OleContainer1.OleObject.Application.ActiveDocument.PrintOut;
end;
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/36002.html
標籤:VCL組件開發及應用
下一篇:如何通過dump定位問題?
