Excel Word VBA variable not defined in Excel macro


Joined
Jan 21, 2009
Messages
1
Reaction score
0
In Microsoft Office Excel 2003, I am attempting to run an Excel macro which executed successfully with an earlier version of Excel, but does not execute now. I get a Microsoft Visual Basic Compile error: Variable not defined" message at the wdWindowStateMinimize statement. What needs to be done so that the variable is recognized when I attempt to execute the macro?

Private Sub automateWord(wsTemp As Worksheet, wsList As Worksheet, FilePath As String)
'Either gets a new instance of Word or uses the existing instance of Word.
Dim myDoc, oWord As Object

On Error GoTo erroh
Set oWord = GetObject(, "Word.application")

oWord.Visible = True
oWord.WindowState = wdWindowStateMinimize
 
Ad

Advertisements


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