ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   HELP Needed, Word mail merge breaks when saved as.. from an Excel Macro (https://www.excelbanter.com/excel-programming/359382-help-needed-word-mail-merge-breaks-when-saved-excel-macro.html)

[email protected]

HELP Needed, Word mail merge breaks when saved as.. from an Excel Macro
 
I need some help, I have an excel Macro that opens a word File. This
Word file has some Merged Fields, when I save it with a different name
all the merged fields brake.
Is there a way of updating the word File.
I paste the code downwards if you can suggest any improvement.
Thanks
-------------------------------------------------------------------
Sub wordchage()

Dim WordApp As Object
Set WordApp = CreateObject("Word.Application")

fpath = ThisWorkbook.Path
Doc = fpath & "\" & ("Base booklet.doc")
Sheets("Incumbent").Select
LetterTemplate = Doc
fname = Range("A3")
fnamedoc = fname & ".doc"

With WordApp
..Documents.Open LetterTemplate
..Visible = False
End With

Application.DisplayAlerts = True
WordApp.ActiveDocument.SaveAs Filename:=fpath & "\" & fnamedoc
WordApp.PrintOut Background:=False ' Prints in PDF - named argument
Filename:= not working
WordApp.NormalTemplate.Saved = True
WordApp.ActiveDocument.Close

Set WordApp = Nothing
Set Doc = Nothing

End Sub



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

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