Excel Word VBA variable not defined in Excel macro

Jan 21, 2009
Reaction score
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

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