Hello,
I am exporting data from a form to a Word template using bookmarks and would like to include an input box which users can use to add additional information which is not stored in the form.
I am getting an If without Else error and not sure if the code is correct. Appreciate your help. Below please find the code:
I am exporting data from a form to a Word template using bookmarks and would like to include an input box which users can use to add additional information which is not stored in the form.
I am getting an If without Else error and not sure if the code is correct. Appreciate your help. Below please find the code:
Code:
Private Sub Command111_Click()
On Error Resume Next
Dim objWord As Object
Dim strPath As String
Dim response As String
Dim MSG As String
Dim MyNote As String
strPath = DLookup("[TemplateLocation]", "TablePath", "[TemplateID]='" & Me.[txtpathLetter] & "'")
Set objWord = CreateObject("Word.Application")
objWord.Visible = False
objWord.Documents.Add strPath
' fields on my form that get exported to Word
objWord.ActiveDocument.Bookmarks("NAME").Select
objWord.Selection.Text = Me.CLFNAME & " " & Me.CLLNAME
' YES/NO Option asking user if certain data is available
' If Yes, type this data using an input box which needs to propagate to the bookmark FileNo
' If NO, then a msgbox will show up
MSG = MsgBox(MyNote, vbYesNo, "Do you have file number?")
If MSG = vbYes Then
Do
response = InputBox("FileNO", "Enter File number")
objWord.ActiveDocument.Bookmarks("FileNo").Select
objWord.Selection.Text = response
Else
response = MsgBox("please manually enter the file no.")
end if
objWord.Visible = True