Displaying optional data when using Word 2003 userform
I've created a template with userform in Word 2003. I know need to include a couple extra sentences (canned ones, always the same) based on either
a check box that I can check in the userform
or ideally,
based on one of the selections in a resident combo box
any help would be appreciated
thanks
Rhonda
Subscribe to get a FREE chapter from Windows 7 The Missing Manual
This month, every Windows Secrets subscriber can download a one-chapter excerpt of Windows 7: The Missing Manual.Windows 7: The Missing Manual provides valuable information to help you overcome these difficulties in learning a new operating system. Subscribe today to download your free excerpt.
Would it be possible for you to post a picture of the userform along with the sentences you want displayed, the conditions that trigger their display, and where on the userform you want them displayed.
Rhonda, I would also like to welcome you to the Lounge.
Open the form, then use Prt Sc to take a snapshot, paste into paint, crop as needed and save to desktop. Go Advanced (in the reply area of the Lounge), Manage Attachments or use paperclip to upload the snapshot you took.
BACKUP...BACKUP...BACKUP
Have a Great Day! Ted
Sony Vaio Laptop, 2.53 GHz Duo Core Intel CPU, 8 GB RAM, 320 GB HD
Win 8 Pro (64 Bit), IE 10 (64 Bit) Complete PC Specs: By Speccy
I assume that you are talking about the "Type of Test" or "Respond to" combo boxes. If so here is what I'd do.
Insert a bookmark in the Document/template where you want to insert the text if the desired option is selected.
In the AfterUpdate event of the appropriate combobox test the current value and if it is the one that gets the extra sentences navigate to the bookmark.
Insert the sentences.
I know these instructions are general, that's because I don't write much VBA in Word I mostly use Access & Excel. If you need further help post back and I'll try to code it out and/or one of the Word experts will jump in I'm sure.
P.S. If you post back include the name of the ComboBox and the Name of the Bookmark you insert. That will allow whoever does the code to use the proper names to give you copy & paste code.
it's the test type combo box, the new bookmark will be called Area_requirements and the pick from the dropdown is "Area Type 1". I don't see an AfterUpdate event on the userform. I had to add this:
Private Sub UserForm_Initialize()
testtype.List = Array("Area Type 1", "Area Type 2", "Area Type 3", "Avalanche Type 1", "Cadaver Type 1", "Cadaver Type 2", "Cadaver Type 3", "Disaster Type 4", "Trailing Type 1", "Trailing Type 2", "Trailing Type 4")
respond_to.List = Array("Area Type 1/2/3", "Area Type 2/3", "Avalanche Type 1", "Cadaver Type 1", "Cadaver Type 2", "Cadaver Type 3", "Disaster Type 4", "Trailing Type 1/2/4", "Trailing Type 2", "Trailing Type 4")
End Sub
The AfterUpdate method is on the ComboBox. So when the selection is made the event is triggered and the code executed.
If you click on your ComboBox control {graphic 1} you'll get the VBA code screen {graphic 2} which has the Change event. Drop down the box on the right and scroll to the top and Click on AfterUpdate to add a stub for that event then fill in your code.
Private Sub UserForm_Initialize()
TestType.List = Array("Area Type 1", "Area Type 2", "Area Type 3", _
"Avalanche Type 1", "Cadaver Type 1", _
"Cadaver Type 2", "Cadaver Type 3", _
"Disaster Type 4", "Trailing Type 1", _
"Trailing Type 2", "Trailing Type 4")
respond_to.List = Array("Area Type 1/2/3", "Area Type 2/3", "Avalanche Type 1", _
"Cadaver Type 1", "Cadaver Type 2", "Cadaver Type 3", _
"Disaster Type 4", "Trailing Type 1/2/4", _
"Trailing Type 2", "Trailing Type 4")
End Sub
Private Sub TestType_AfterUpdate()
Dim zMyValue As String '*** Use variable so you don't repeatedly fetch value.
zMyValue = TestType.Value
MsgBox "The selection in TestType is: " & zMyValue
If zMyValue = "Area Type 1" Then
'*** Put code here to locate bookmark & insert sentences
End If
End Sub
P.S. The AfterUpdate event does not fire until you leave the TestType dropdown!