主题:  How to fire a macro in Word

cjalex

职务:普通成员
等级:1
金币:0.0
发贴:2
注册:2003/3/5 14:31:36
#12003/5/19 12:24:29
How to fire a macro in Word through COM

Hello all,I'm trying to fire a MS-Word macro from CF.
I don't think I've got the syntax right.
I've attached the code: It breaks at: objWord.run("testword");
Any help or hints will be appreciated.
Thanks!



ACTION="CONNECT"
CLASS="Word.Application"
NAME="objWord"
TYPE="COM">


ACTION="CREATE"
CLASS="Word.Application"
NAME="objWord"
TYPE="COM">










// open Word in the background
objWord.Visible = false;

// disable Alerts such as: 'Save this document?'
objWord.DisplayAlerts =false;

// get the 'Documents' collection
objDoc = objWord.Documents;

//open the HTML document
newDoc = objDoc.open("C:\test.doc");


objWord.run("testword");

// save it as a new document
newDoc.SaveAs("C:\test1.doc",Val(1));

// close the document
newDoc.Close();
objWord.Quit();
//release the object
objWord = "Nothing";




**************************************************
MS-Word CODE(The macro I created was named "testword"):

Public Sub testword()

Selection.TypeText Text:="test"
End Sub

******************************************************
TextText

编辑历史:[这消息被cjalex编辑过(编辑时间2003-05-19 12:27:22)]


s22

职务:版主
等级:4
金币:10.0
发贴:1634
注册:2004/12/19 13:06:46
#22003/5/28 23:35:07
你把英语改为中文我就帮你



wait

职务:普通成员
等级:1
金币:10.0
发贴:220
注册:2002/10/19 11:02:36
#32003/5/29 6:50:45
s22在上个帖子中说
引用:
你把英语改为中文我就帮你


同意,这事就交给你来办了。



阿育神经

职务:普通成员
等级:1
金币:0.0
发贴:4
注册:2003/5/1 0:36:14
#42003/6/8 22:51:07
我来翻....

How to fire a macro in Word through COM
如何通过CF来执行word的宏!

Hello all,I'm trying to fire a MS-Word macro from CF.
I don't think I've got the syntax right.
我不知道我的语句的语法表达是否正确

I've attached the code: It breaks at: objWord.run("testword");
我已经添加了代码...但是在objWord.run("testword"); 这里就中断了!

Any help or hints will be appreciated.
不胜感激!

Thanks!

编辑历史:[这消息被阿育神经编辑过(编辑时间2003-06-08 22:51:39)]


s22

职务:版主
等级:4
金币:10.0
发贴:1634
注册:2004/12/19 13:06:46
#52003/6/19 9:07:50
office 97跟office200...xp执行命令会有区别,命令也不一定相同

MSDN上有2000版本的开发文档。