[Excel]Excel to open word-file with mail merge

pverstraten

New Member
Joined
Apr 13, 2015
Messages
3
I have an Excel-macro which alters a file, saves it and opens a word file, containing a Mail merge, based on the just saved file. But if I run it, it just opens the file, not making the connection. Anyone who can help me with this?

I'd like to open it From Excel, so that the user input is minimal (and therefore less errors).
Code:
Code:
Sub Excel_macro()
 '
 ' Excel_macro Macro

 '
 '
 '
 Dim fn_basis As Variant
 fn_basis = "C:\file.csv"
 Workbooks.OpenText Filename:=fn_basis, _
 DataType:=xlDelimited, Semicolon:=True, Local:=True
 ...
 'Opslaan naar bestand
 Dim fn As Variant
 fn = "C:\fileformailmerge.csv"
 Application.DisplayAlerts = False
 ActiveWorkbook.SaveAs Filename:=fn, Local:=True
 ActiveWindow.Close False
 Application.DisplayAlerts = True
 'Openen Word
 Dim objWord As Object
 Set objWord = CreateObject("Word.Application")
 objWord.Visible = True
 objWord.Documents.Open "C:\Mailmerge.docx"
 'Sluiten Excel
 Application.Quit
 End Sub

If I comment out "objWord.Documents.Open "C:\Mailmerge.docx"" the files doesn't get opened, but when I do it manually everything is fine. If ran as the code above, the docx gets opened, but no connection is made.

How can I fix this?
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

Forum statistics

Threads
1,215,325
Messages
6,124,252
Members
449,149
Latest member
mwdbActuary

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