I'm new to writting code and am getting an error add "Compile Error: Variable not defined" on the text "txtDate = ActiveDocument.Variables("Date")"
Any help would be great!
Thank you,
SMOO
Code:
Option Explicit
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdOK_Click()
' Prevent variable from being deleted
If txtDate = "" Then txtDate = " "
ActiveDocument.Variables("Date") = txtDate
If txtClient_Name = "" Then txtClient_Name = " "
ActiveDocument.Variables("Client Name") = txtClient_Name
If txtClient_ID_# = "" Then txtClient_ID_# = " "
ActiveDocument.Variables("Client ID #") = txtClient_ID_#
' Update fields in document
ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.Fields.Update
Unload Me
End Sub
Private Sub UserForm_Initialize()
' Load variables into text boxes
On Error Resume Next
txtDate = ActiveDocument.Variables("Date")
txtClientName = ActiveDocument.Variables("Client Name")
txtClientID# = ActiveDocument.Variables("Client ID #")
End Sub
Any help would be great!
Thank you,
SMOO