I created a word template with placeholders such as <> that I am then able to replace automatically with my excel macro. When I tried this process again, the word document now opens saying it is a read only document. How am I supposed to save my Word Template so it can be edited? Also, when I open the word template through my excel macro, how does it know to save it as a new word document, and not save it as an updated template?
Here is my code:
Sub ReplaceText() Dim wApp As Word.Application Dim wDoc As Word.Document Set wApp = CreateObject("Word.Application") wApp.Visible = True Set wDoc = wApp.Documents.Open("file name here") With wDoc .Application.Selection.Find.Text = "<<name>>" .Application.Selection.Find.Execute .Application.Selection = Range("A5") .Application.Selection.EndOf .Application.Selection.Find.Text = "<<dob>>" .Application.Selection.Find.Execute .Application.Selection = Range("A6") .SaveAs2 Filename:=("file name goes here"), _ FileFormat:=wdFormatXMLDocument, AddtoRecentFiles:=False End With End Sub