G
GastonFranzini
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
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