VBA Code to open Word doc (Mail Merge)

kidwispa

Active Member
Joined
Mar 7, 2011
Messages
330
Hi All,

I've been searching for a solution for this and I think I'm half way there.

In one of my workbookss (tab called "Dashboard") I have a command button that opens a specific word document. This word document is a Mail Merge form that is linked to another tab in the same workbook called "Data". The code I found online opens the correct word document, however it doesn't offer me the message that pops up that says "Opening this document will run the following SQL command: SELECT * FROM 'Data$'..." as it does when I open it manually.

Is there a way to edit the code so it gives me this option when I click the command button?

Thanks in advance for any suggestions/fixes :)

Code:
Sub OpenWordFedExDoc()
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("G:\Insurance Claims\Claims Forms\FedEx Claim Form.doc")
wdApp.Visible = True
End Sub
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

Forum statistics

Threads
1,224,604
Messages
6,179,857
Members
452,948
Latest member
UsmanAli786

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
Back
Top