Word Macro Doesn't Work

P

peter.mcclymont

Hi All,

I am trying to run a word macro from within a vb script that looks
like this,



Sub StartNewMacro()
'
' StartNewMacro Macro
'
Set app = CreateObject("Word.Application")
Set doc = app.Documents.Open("C:\\MOM\\Test.doc", False, True,
False, , , True, , , wdOpenFormatAuto, , True)
Set returnValue = AddIns.Add("C:\\MOM\\WebPublisher.dot", True)
app.Run ("ConvertHTML")
app.Run ("ConvertHTMLBatch")

End Sub



So basically I have a document called test.doc which I want to apply
the macro to, and the macro is in the WebPublisher.dot file. The
test.doc file will eventually become any file, and can be different
every time hence the reason they are both in a separate document.

Now though when the execution gets to the app.Run command I get the
error message,

Run-time error '-2147352573 (800020003)':

Unable to run the specified macro

Any ideas?
 
J

Jonathan West

Hi All,

I am trying to run a word macro from within a vb script that looks
like this,



Sub StartNewMacro()
'
' StartNewMacro Macro
'
Set app = CreateObject("Word.Application")
Set doc = app.Documents.Open("C:\\MOM\\Test.doc", False, True,
False, , , True, , , wdOpenFormatAuto, , True)
Set returnValue = AddIns.Add("C:\\MOM\\WebPublisher.dot", True)
app.Run ("ConvertHTML")
app.Run ("ConvertHTMLBatch")

End Sub



So basically I have a document called test.doc which I want to apply
the macro to, and the macro is in the WebPublisher.dot file. The
test.doc file will eventually become any file, and can be different
every time hence the reason they are both in a separate document.

Now though when the execution gets to the app.Run command I get the
error message,

Run-time error '-2147352573 (800020003)':

Unable to run the specified macro

Any ideas?

Shouldn't this line

Set returnValue = AddIns.Add("C:\\MOM\\WebPublisher.dot", True)

be this?

Set returnValue = app.AddIns.Add("C:\\MOM\\WebPublisher.dot", True)
 
P

peter.mcclymont

Shouldn't this line

Set returnValue = AddIns.Add("C:\\MOM\\WebPublisher.dot", True)

be this?

Set returnValue = app.AddIns.Add("C:\\MOM\\WebPublisher.dot", True)

Thanks so much! That worked.

This is my first look at word macros (I am a C# developer) so it is a
bit different.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top