Hi,
I have a microsoft word template that merges values from a database and generates an order form as a new document. The order form has a checkbox that I want to make sure the user checks. I wrote the following macro to prevent the user from being able to print the order form unless he checks one of the boxes.
Sub FilePrint()
Dim lngRed As Long, lngWhite As Long
Dim errorsw As String
Dim stLinkCriteria As String
lngRed = RGB(255, 0, 0)
lngWhite = RGB(255, 255, 255)
If LCase(Right(ActiveDocument.Name, 4)) = ".dot" Then
ActiveDocument.PrintOut
Exit Sub
End If
If ActiveDocument.CheckBox1.value = False And ActiveDocument.CheckBox2.value = False Then
MsgBox "Is this Job Taxable?", vbInformation, "QuoteBuilder"
ActiveDocument.CheckBox1.BackColor = lngRed
ActiveDocument.CheckBox2.BackColor = lngRed
errorsw = "y"
Else
ActiveDocument.CheckBox1.BackColor = lngWhite
ActiveDocument.CheckBox2.BackColor = lngWhite
End If
End Sub
So far so good... the only problem is I need to put this macro in the normal.dot global template for it to work. Obviously, I don't want this code running any time a word document is created because it will yield an error.
I was thinking I could add a piece of code that checks if "CheckBox1" exists before executing the code but haven't been able to get it to work. I am also open to any other ideas.
Thank you
I have a microsoft word template that merges values from a database and generates an order form as a new document. The order form has a checkbox that I want to make sure the user checks. I wrote the following macro to prevent the user from being able to print the order form unless he checks one of the boxes.
Sub FilePrint()
Dim lngRed As Long, lngWhite As Long
Dim errorsw As String
Dim stLinkCriteria As String
lngRed = RGB(255, 0, 0)
lngWhite = RGB(255, 255, 255)
If LCase(Right(ActiveDocument.Name, 4)) = ".dot" Then
ActiveDocument.PrintOut
Exit Sub
End If
If ActiveDocument.CheckBox1.value = False And ActiveDocument.CheckBox2.value = False Then
MsgBox "Is this Job Taxable?", vbInformation, "QuoteBuilder"
ActiveDocument.CheckBox1.BackColor = lngRed
ActiveDocument.CheckBox2.BackColor = lngRed
errorsw = "y"
Else
ActiveDocument.CheckBox1.BackColor = lngWhite
ActiveDocument.CheckBox2.BackColor = lngWhite
End If
End Sub
So far so good... the only problem is I need to put this macro in the normal.dot global template for it to work. Obviously, I don't want this code running any time a word document is created because it will yield an error.
I was thinking I could add a piece of code that checks if "CheckBox1" exists before executing the code but haven't been able to get it to work. I am also open to any other ideas.
Thank you