调用OLEFUNCTION时产生错误,调试半天无果,望指点,谢谢
Variant vWordApp,vWordDoc,vSelect
FileName=CurrentPrgPath+ "\\ychtmp.doc ";
vWordApp=CreateOleObject( "Word.Application ");
vWordDoc=vWordApp.OlePropertyGet( "Documents ").OleFunction "Open ",FileName.c_str() );
vWordApp.OlePropertySet( "Visible ",true);
vSelect = vWordApp.OlePropertyGet( "Selection ");
//将SELECTION 指向特定书签(mBookMark),并在书签处插入新的内容
vSelect=vSelect.OleFunction( "GoTo ", "wdGoToBookmark ", " ", " ", "mBookMark ");
以上语句段当执行至最后一句时(即注释的下面那句),总是会报错.
我也查了相关的VBA,做了很多的调试,始终不得其解.
希望哪位大哥知晓原因的可以帮助在下.万分感谢!!
[解决办法]
vSelect = vSelect.OleFunction( "GoTo ",
-1, // What:=wdGoToBookmark
"你的书签名称 " // Name:= "书签名 "
);
[解决办法]
在VBA里的直接窗口里输入 "?wdGoToBookmark " 得知 其值为-1
vSelect=vSelect.OleFunction( "GoTo ",-1,0,0, "mBookMark ");