Run Word Macro from excel, HELP!


Posted by RoB on October 09, 2001 3:27 PM

I found some code in the Archive 2 by Ivan I think, but I'm having problems. Here is my code (excel 2000):

Sub RunWordMerge()

Dim WordObj As Word.Application
Set WordObj = CreateObject("word.application")
With WordObj
.Documents.Open "S:\FileServer\Shared Files\DataBases\2000 Files DB\Refi Mass Mailer.doc"
.Visible = True 'Or False if you don't want it visible
.Run "MergeMacro"
.Quit
End With
Set WordObj = Nothing


Workbooks("2000 Files Input Screen.xls").Activate

End Sub

When i run it, im getting the error "Compile Error: User-defined type not defined." Can someone help me?? Thanks :)

Posted by RoB on October 09, 2001 3:28 PM

Also...

the line :

Dim WordObj As Word.Application

is highlighted when i get that error. Thanks



Posted by Dank on October 10, 2001 3:18 AM

Re: Also...

In the VB editor click Tools, References and tick Microsoft Word n.0 Object library where n will depend on the version of Word you have installed.

Regards,
Daniel.