D
doublehu
Unregistered / Unconfirmed
GUEST, unregistred user!
为了使用Office CommandBarButton v.1.0 (http://www.torry.net/ole.htm)控制Word。在用OleContainer打开Word后,通过OleObject获得当前Word对象,但类型是Variant,
WordDocument :Variant;
OleContainer.CreateObject('Word.Document.8',False);
OleContainer.DoVerb(XXXX);
WordDocument := OleContainer.OleObject;
// New on the Standardbar
CommandbarbuttonWordNew.connectto(
// You have to cast it yourself
Commandbarbutton(
// Find the button you want to hook
WordDocument.CommandBars.Item['Standard'].Controls.Item[1]));
//WordDocument.CommandBars.Item['Standard'].Controls.Item[1])获得的是Variant类型,而不是CommandBarButtonControl,编译时错误提示:Invalid typecast
WordDocument :Variant;
OleContainer.CreateObject('Word.Document.8',False);
OleContainer.DoVerb(XXXX);
WordDocument := OleContainer.OleObject;
// New on the Standardbar
CommandbarbuttonWordNew.connectto(
// You have to cast it yourself
Commandbarbutton(
// Find the button you want to hook
WordDocument.CommandBars.Item['Standard'].Controls.Item[1]));
//WordDocument.CommandBars.Item['Standard'].Controls.Item[1])获得的是Variant类型,而不是CommandBarButtonControl,编译时错误提示:Invalid typecast