Hi,
I would like to export a form entry to a word template. I have VBA code connected to a command button, however, although a new word document opens upon execution, the fields are not populated (the word document remains empty). Please advise!
here is my code:
Private Sub Command694_Click()
Dim WordApp As Word.Application
Dim doc As Word.Document
On Error Resume Next
Error.Clear
Set WordApp = GetObject(, "Word.Application")
If Err.Number <> 0 Then
Set WordApp = New Word.Application
WordApp.Visible = True
End If
Set doc = WordApp.Documents.Open("path removed for anonymity", , True)
With doc
.FormFields("fldProjectName").Result = Me.ProjectName
.FormFields("fldProjectDetail").Result = Me.ProjectDetail
End With
WordApp.Visible = True
WordApp.Activate
Set doc = Nothing
Set WordApp = Nothing
End Sub
I would like to export a form entry to a word template. I have VBA code connected to a command button, however, although a new word document opens upon execution, the fields are not populated (the word document remains empty). Please advise!
here is my code:
Private Sub Command694_Click()
Dim WordApp As Word.Application
Dim doc As Word.Document
On Error Resume Next
Error.Clear
Set WordApp = GetObject(, "Word.Application")
If Err.Number <> 0 Then
Set WordApp = New Word.Application
WordApp.Visible = True
End If
Set doc = WordApp.Documents.Open("path removed for anonymity", , True)
With doc
.FormFields("fldProjectName").Result = Me.ProjectName
.FormFields("fldProjectDetail").Result = Me.ProjectDetail
End With
WordApp.Visible = True
WordApp.Activate
Set doc = Nothing
Set WordApp = Nothing
End Sub