1. How can MS script directly access Word 2003 objects?
2. How can MS script run Word 2003 macro such as normal.module1.myMacro?
Thanks.
Access to Word 2003 VBA Macro
Moderators: JRL, Dorian (MJT support)
I'm not certain but perhaps something like what is explained for Excel here:
http://www.mjtnet.com/forum/viewtopic.php?t=3825
http://www.mjtnet.com/forum/viewtopic.php?t=3825
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Code: Select all
VBSTART
Sub RunWordAndMacro(doc,macro)
Dim WordApp As Object
Set WordApp = CreateObject("Word.Application")
WordApp.Visible = True
WordApp.documents.Open doc
WordApp.Run macro
WordApp.Quit
End Sub
VBEND
VBRun>RunWordAndMacro,c:\somedoc.doc,MyMacro
Last edited by Marcus Tettmar on Sat Apr 12, 2008 6:48 am, edited 1 time in total.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Macrus,
When trying out your suggested script:
VBSTART
Sub RunWordAndMacro(doc,macro)
Dim WordApp As Object
Set WordApp = CreateObject("Word.Application")
WordApp.Visible = True
WordApp.documents.Open doc
WordApp.Run macro
WordApp.Quit
End Sub
VBEND
VBRun>RunWordAndMacro,C:\Temp\¤å¥ó.rtf,Sub_assignObj
I encounter the following error:
Microsoft VBScript compilation error:1025
Expected end of statement
Line 3, Column 14
I don't understand why. Line 3 is just a simple delcaration: Dim WordApp As Object.
Please help. Thanks.
When trying out your suggested script:
VBSTART
Sub RunWordAndMacro(doc,macro)
Dim WordApp As Object
Set WordApp = CreateObject("Word.Application")
WordApp.Visible = True
WordApp.documents.Open doc
WordApp.Run macro
WordApp.Quit
End Sub
VBEND
VBRun>RunWordAndMacro,C:\Temp\¤å¥ó.rtf,Sub_assignObj
I encounter the following error:
Microsoft VBScript compilation error:1025
Expected end of statement
Line 3, Column 14
I don't understand why. Line 3 is just a simple delcaration: Dim WordApp As Object.
Please help. Thanks.
After removing the statement--Dim WordApp As Object, the script can run but generate the following Macro Scheduler error:
Forms.Form.1 :-2147352573
Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus.
Line 8, Column 2
How can I resovle the problem?
Forms.Form.1 :-2147352573
Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus.
Line 8, Column 2
How can I resovle the problem?