I am using data in an Excel sheet to populate bookmarks in a Word document template, see code below for details. To this point, the macro operates perfectly but I am now struggling to place data against an additional bookmark located in the header of the Word template and would appreciate some assistance.
Code:
Sub Create_Contract_Directories()
ActiveSheet.Cells(ActiveCell.Row, 1).Select
Dim Reference As Variant
Reference = ActiveCell.Value
ActiveCell.Offset(0, 1).Range("A1").Select
Dim Site As Variant
Site = ActiveCell.Value
ActiveCell.Offset(0, 1).Range("A1").Select
Dim Project As Variant
Project = ActiveCell.Value
Dim appWord As Word.Application
Dim aDoc As Word.Document
Set appWord = CreateObject("Word.Application")
Set aDoc = appWord.Documents.Open(Filename:="C:\Template.dot")
aDoc.Application.Visible = True
aDoc.Bookmarks("Reference").Range.Text = Reference
aDoc.Bookmarks("Site").Range.Text = Site
aDoc.Bookmarks("Project").Range.Text = Project
aDoc.SaveAs Filename:="C:\Template1.doc"
aDoc.Close
Set aDoc = Nothing
appWord.Quit
Set appWord = Nothing
End Sub