Hello All,
I am a nu-B and don’t know much about programming. I have been tasked with converting WP 5.1 macros to Word XP and boy, do I need help!
I have created a template, and am using InputBoxes to gather information to be plugged into the document. At one point the user will have to make a decision as to whether a document was recorded in a Volume/Page or a Transaction. I have created a UserForm with 2 radio buttons allowing the user to choose one or the other. I need the UserForm to appear at the right time, but keep getting an error 91 “Object variable or With block variable not set.” My question is: How do I set an object variable?
Here is my code so far:
Private Sub Document_New()
'declare vars
Dim strCaseNum, strDefName, strCrimCrt As String
Dim strVolume, strPage, strTransNum As String
Dim frmVolumePageOrTransaction As UserForm
Dim optVolumePage As OptionButton
'set name vars to input
strCaseNum = InputBox("Enter the Case Number."
strDefName = InputBox("Enter the Defendant's Name."
strCrimCrt = InputBox("Enter the Numbered Court."
frmVolumePageOrTransaction.Show
If optVolumePage = True Then
strVolume = InputBox("Enter The Volume Number."
strPage = InputBox("Enter The Page Number."
Else
strTransNum = InputBox("Enter the Transaction Number"
End IfstrVolume = InputBox("Enter The Volume Number."
strPage = InputBox("Enter The Page Number."
strTransNum = InputBox("Enter the Transaction Number"
'set field results to name vars
ActiveDocument.FormFields("Text1"
.Result = strCaseNum
ActiveDocument.FormFields("Text2"
.Result = strDefName
ActiveDocument.FormFields("Text3"
.Result = strCrimCrt
ActiveDocument.FormFields("Text7"
.Result = strVolume
ActiveDocument.FormFields("Text8"
.Result = strPage
ActiveDocument.FormFields("Text9"
.Result = strTransNum
End Sub
Any help would be appreciated before I become bald!!
Gwynne
I am a nu-B and don’t know much about programming. I have been tasked with converting WP 5.1 macros to Word XP and boy, do I need help!
I have created a template, and am using InputBoxes to gather information to be plugged into the document. At one point the user will have to make a decision as to whether a document was recorded in a Volume/Page or a Transaction. I have created a UserForm with 2 radio buttons allowing the user to choose one or the other. I need the UserForm to appear at the right time, but keep getting an error 91 “Object variable or With block variable not set.” My question is: How do I set an object variable?
Here is my code so far:
Private Sub Document_New()
'declare vars
Dim strCaseNum, strDefName, strCrimCrt As String
Dim strVolume, strPage, strTransNum As String
Dim frmVolumePageOrTransaction As UserForm
Dim optVolumePage As OptionButton
'set name vars to input
strCaseNum = InputBox("Enter the Case Number."
strDefName = InputBox("Enter the Defendant's Name."
strCrimCrt = InputBox("Enter the Numbered Court."
frmVolumePageOrTransaction.Show
If optVolumePage = True Then
strVolume = InputBox("Enter The Volume Number."
strPage = InputBox("Enter The Page Number."
Else
strTransNum = InputBox("Enter the Transaction Number"
End IfstrVolume = InputBox("Enter The Volume Number."
strPage = InputBox("Enter The Page Number."
strTransNum = InputBox("Enter the Transaction Number"
'set field results to name vars
ActiveDocument.FormFields("Text1"
ActiveDocument.FormFields("Text2"
ActiveDocument.FormFields("Text3"
ActiveDocument.FormFields("Text7"
ActiveDocument.FormFields("Text8"
ActiveDocument.FormFields("Text9"
End Sub
Any help would be appreciated before I become bald!!
Gwynne