Step through a Word macro called from Excel?

E

Ed

I have a Word 2000 template with an AutoNew macro. This is called by a
macro in Excel. I need to make some changes to the Word macro, but I can't
seem to figure out how to step through it to see what's happening. I can
step through the Excel macro, but when it hits
Set WD = CreateObject("Word.Application")
WD.Documents.Add
the Word document and actions are invisible, and I can't see the steps.

Any suggestions?

Ed
 
R

Ron de Bruin

Try this

Sub test()
Dim oApp As Word.Application
On Error Resume Next
Set oApp = GetObject(, "Word.Application")
If Err <> 0 Then
Set oApp = CreateObject("Word.Application")
End If

oApp.Activate
oApp.Visible = True
oApp.Documents.Add

'do things

'oApp.ActiveDocument.Close wdDoNotSaveChanges
'oApp.Quit

Set oApp = Nothing
End Sub
 
E

Ed

Thanks, Ron - but I'm a bit lost in using this. Is this a separate Excel
Sub to allow me to walk through my template code? Or should I put this in
my existing Excel code?

Ed
 
R

Ron de Bruin

The Excel sub open Word and make it visible and add a document for you
the Word document and actions are invisible

You can see your Word document now with
It will not walk through your Word template code
You must do that in Word VBA
 

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