View Full Version : Solved: Run a Word VBA from Excel VBA

01-15-2006, 04:38 PM

I'm writing some code for Excel which will run through a list of file names and open and print them. Some of the files are Excel, some Word, some PDF etc.

I've got the code for doing this and I'm really pleased.

The problem I have is that when a couple of the Word files open I actually want to run a Word macro (to be found in normal.dot) and when that finishes the Excel code continues.

How do I get the Word code to run?


Ken Puls
01-15-2006, 05:50 PM
Hi chrismc,

Try looking up the Run method. It can be used to run macros in other files. I believe that the following should work for you for a word document. (Obviously, you'll need to update the path to normal.dot though.
Application.Run "C:\Test.doc!MyMacro"


01-16-2006, 02:46 AM
Thanks - I'll try it.


01-21-2006, 04:33 PM
This is what worked for me using your idea about run.

Sub FromExcel()
Dim wdApp As Object
Set wdApp = GetObject(, "Word.Application")
wdApp.documents.Open "c:\temp\go.doc" 'This is the document containing the macro
wdApp.Run "mymsg" 'This is the macro to run
Set wdApp = Nothing
End Sub

Ken Puls
01-23-2006, 03:54 PM
Hi Chris,

My apologies for not mentioning that you'd probably need to bind to the Word instance to run it. Glad you got it figured out. :)

10-11-2006, 08:30 AM

I'm fairly new to VBA and have a questions regarding the above code.

I've edited the code so the target file is a different one but I'm getting a runtime code when it runs (or doesn't!)

ActiveX component can't create object or return reference to this object (Error 429)

and was wondering what this was to do with and if you have any solutions to solve it.

Thanks much


10-11-2006, 08:52 AM
Hi Trubble,

I've had error 429 in some of my code. Usually when trying to get Excel to do something with Outlook when Outlook isn't running.

I honestly can't remember details so hopefully someone more switched than I am will give you a better answer. I think you need to do a search on the forum for late binding and early binding. These are two slightly different ways of getting applications to talk to each other. Depending which you use I think you have to set up references in VBA (Tools, References, select relevant Object Libraries).

I hope this points you in the right direction.


Ken Puls
10-11-2006, 10:57 AM
Hi there,

There is a brief discussion on early vs late binding (http://www.excelguru.ca/node/13) on my site. The article also links to a more detailed explanation of how to program it at Bob Phillips site.