ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Step through a Word macro called from Excel? (https://www.excelbanter.com/excel-programming/291653-step-through-word-macro-called-excel.html)

Ed[_9_]

Step through a Word macro called from Excel?
 
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



Ron de Bruin

Step through a Word macro called from Excel?
 
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


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Ed" wrote in message ...
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





Ed[_9_]

Step through a Word macro called from Excel?
 
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

"Ron de Bruin" wrote in message
...
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


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Ed" wrote in message

...
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







Ron de Bruin

Step through a Word macro called from Excel?
 
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
oApp.Activate
oApp.Visible = True


It will not walk through your Word template code
You must do that in Word VBA



--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Ed" wrote in message ...
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

"Ron de Bruin" wrote in message
...
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


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Ed" wrote in message

...
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









Ed[_9_]

Step through a Word macro called from Excel?
 
Thank you. I'll work with this. I appreciate the help.

Ed

"Ron de Bruin" wrote in message
...
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
oApp.Activate
oApp.Visible = True


It will not walk through your Word template code
You must do that in Word VBA



--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Ed" wrote in message

...
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

"Ron de Bruin" wrote in message
...
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


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Ed" wrote in message

...
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












All times are GMT +1. The time now is 11:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com