Automating Word from Excel, then running macros?

haw

Board Regular
Joined
Jan 18, 2005
Messages
113
I am using the following VBA code to open a Word (2000 SP3) document from an Excel-based macro. After the document is open, I need to:
1) answer yes/no to a pop-up question from Word asking if I want to update the Links in the Word document
2) answer disable/enable to the pop-up question from Word asking if I want to enable/disable Macros in the document (I digitally sign the macros eventually, so this isn't a long-term problem, but it's a pain to sign the macros during development and if there's an easy way to say "yes" to the pop-up question then I'd like to know how)
3) MOST IMPORTANT!!!: once the Word document is really active, I need to fire off a couple of VBA macros that I've written and which reside in the word document.

I'm about to start looking at how to move the Word macros over to my Excel VBA project ... but I'd really rather leave them in the word document and fire them off from my "calling macro."

Any ideas / help would be appreciated.

-----------------
Dim wdApp As Word.Application, wdDoc As Word.Document
On Error Resume Next
Set wdApp = GetObject(, "Word.Application")
If Err.Number <> 0 Then 'Word isn't already running
Set wdApp = CreateObject("Word.Application")
End If
On Error GoTo 0
Set wdDoc = wdApp.Documents.Open _
("C:\Data\Contract.doc")
wdApp.Visible = True
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

XL-Dennis

Well-known Member
Joined
Jul 27, 2002
Messages
1,920
Check out the Application.Run statement in the directhelp.

In Your situation You need to replace Application with:
wdApp.Run
 

Forum statistics

Threads
1,148,216
Messages
5,745,436
Members
423,951
Latest member
peggrif

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top