If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
VBA code works in .doc but not .dot template file
I've created a test Word form for which I'm testing for uncompleted fields, including radio buttons, when users use the form as a template. The radio buttons are in 3 groups and all groups must be selected. If they are not, prompts display that force users to enter the number for the button they want to select. The validation macros are run on the print command and appear below.
All the code works perfectly in the .doc file, but when I save it as a .dot, the text field validation works fine, but the radio button code does not. I've stepped through this code and even though the button condition is false, the program skips over the "if" statements. And if I select the buttons in the document, I still get the prompts, so the selection is not being read. Again, none of this happens in the .doc file, only in the .dot. I have no idea why; if anybody out there does know why, I'd appreciate a solution. The files are too big to attach. Sub MandOpt1() 'Tests Opt1 button group for no selection Dim sPrompt As String Dim sUserResp As String Dim iUR As Integer If OptionButtonOrigNew = False And _ OptionButtonRevision = False Then sPrompt = "1. Original (New)" + vbCrLf sPrompt = sPrompt + "2. Revision" + vbCrLf iUR = 0 While iUR 1 Or iUR 2 sUserResp = InputBox(sPrompt, "The Document is....") iUR = Val(sUserResp) Wend Select Case iUR Case 1 OptionButtonOrigNew = True Case 2 OptionButtonRevision = True End Select End If End Sub Sub MandOpt2() 'Tests Opt2 button group for no selection Dim sPrompt As String Dim sUserResp As String Dim iUR As Integer If OptionButtonProcedure = False And _ OptionButtonForm = False And _ OptionButtonMarketing = False And _ OptionButtonRMS = False And _ OptionButtonRMSOther = False Then sPrompt = "1. Procedure" + vbCrLf sPrompt = sPrompt + "2. Form" + vbCrLf sPrompt = sPrompt + "3. Marketing" + vbCrLf sPrompt = sPrompt + "4. RMS" + vbCrLf sPrompt = sPrompt + "5. Other" iUR = 0 While iUR 1 Or iUR 5 sUserResp = InputBox(sPrompt, "The Document Type is....") iUR = Val(sUserResp) Wend Select Case iUR Case 1 OptionButtonProcedure = True Case 2 OptionButtonForm = True Case 3 OptionButtonMarketing = True Case 4 OptionButtonRMS = True Case 5 OptionButtonRMSOther = True End Select End If End Sub Sub MandTR() 'Tests TR button group for no selection Dim sPrompt As String Dim sUserResp As String Dim iUR As Integer If OptionButtonNoTrainNeeded = False And _ OptionButtonTrainNeeded = False And _ OptionButtonSAGE = False Then sPrompt = "1. No Training Needed" + vbCrLf sPrompt = sPrompt + "2. Training Needed" + vbCrLf sPrompt = sPrompt + "3. Self-Study (Record on SAGE)" + vbCrLf iUR = 0 While iUR 1 Or iUR 3 sUserResp = InputBox(sPrompt, "The Training Requirement is....") iUR = Val(sUserResp) Wend Select Case iUR Case 1 OptionButtonNoTrainNeeded = True Case 2 OptionButtonTrainNeeded = True Case 3 OptionButtonSAGE = True End Select End If End Sub |
Thread Tools | |
Display Modes | |
|
|