FilePrint Macro Issues

Joined
Sep 13, 2006
Messages
1
Reaction score
0
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top