VBA里面的帮助代码里的示例: If Application.PrintPreview = False Then ActiveDocument.PrintPreview End If我在delphi里的代码: procedure TForm2.P1Click(Sender: TObject); begin Caption:=OleContainer1.OleObject.Application.ActiveDocument.Name; OleContainer1.OleObject.Application.ActiveDocument.PrintPreview; end;caption可以正常显示出来了,但就是不能打印出来,老是提示说所需视图无效!!请问怎么解决这个问题啊
olecontainer1.oleobject.ativedocument.save();
打印:
olecontainer1.oleobject.ativedocument.print();
不知道我有没有记错,你看一下vba for word帮助吧。
然后把命令加在Delphi里面就可以了。
请问能不能把那个文件菜单项找回来呢?
还有一个问题,在哪个事件里可以知道里面的内容已经被修改了,也就是说在哪个地方检查olecontainer1.modifed。
能具体一些吗?可否贴一些代码上来呢?
用activedocument.printpreview方法。兄弟,你这样问也不是办法啊,装word时把vba帮助装上不就有了。不过在olecontainer的情况下不一定好用。
If Application.PrintPreview = False Then
ActiveDocument.PrintPreview
End If我在delphi里的代码:
procedure TForm2.P1Click(Sender: TObject);
begin
Caption:=OleContainer1.OleObject.Application.ActiveDocument.Name;
OleContainer1.OleObject.Application.ActiveDocument.PrintPreview;
end;caption可以正常显示出来了,但就是不能打印出来,老是提示说所需视图无效!!请问怎么解决这个问题啊
如果不要求显示在你自已的界面中的话用ole控制,这种方法最好。
仔细观察了一下,发现word里的打印按钮可用,预览按钮不可用,在delphi里
相应地OleContainer1.OleObject.application.ActiveDocument.PrintOut;可用OleContainer1.OleObject.Application.ActiveDocument.PrintPreview;不可用。看来用代码是无法实现的。唯一的做法只能是先保存,再用OLE调用打印预览的功能了。十分感谢robinhunter(深空)的帮助!!