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:
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?
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?