Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dropdown box in word form 1

Status
Not open for further replies.

ajking

Technical User
Aug 13, 2002
229
I have created a form in Word with a dropdown box with two items 'text1' and 'text2' Is it possible to programmitically change the font colour depending which item is selected?
failing that is it possible to change a referenced textbox's background colour depending wich selection is made in the dropdown box? TIA

'Life is what happens to you while you are busy making other plans' John W. Lennon 1940-1980
 
Basically you have to create an array, which contains the Color "words" (i.e. Blue, red, a.s.o.) and their Word-values (e.g. wdColorBlue).
Then you can put this in your button_click() code:
selection.Font.Color=the respective field of your array

You can use the Selection.whatever method to assign fonts, colors, highlighting, ...

If you need the respective Word-internal methods, I'd recommend you simply record a macro where you assign different colors to text, textboxes a.s.o.

Does that help you? :)
MakeItSo

Andreas Galambos
EDP / Technical Support Specialist
(andreas.galambos@bowneglobal.de)
HP:
 
Hi Andreas (that's what I call a fast response)
I can see where you are coming from and I am fairly well versed in VB programming in Access and Excel but word forms don't seem to follow the same methods.
So when you say in your button_click() code where do I find the properties to activate the on_click or after_update event(if there is one) of the Drop down box?
regards
Alan

'Life is what happens to you while you are busy making other plans' John W. Lennon 1940-1980
 
Hi Alan,
Just double click on the drop down or the button in design mode.
VB Editor will then open with a "Sub ... _Change()" or "Sub..._Click()" procedure ready.
[pipe]
Andreas

It is impossible to make anything foolproof, because fools are so ingenious. - Murphy's 11th Law
 
Hi Andreas
Sorry to be a pain but I doubleclicked the dropdown field but it doesn't open VB coding only the properties. I know in Access and Excel you double click the form control to get VBA but Word doesn't seem to do that.
If I Alt-F11 I get the VB screen but no indication of form controls.
Am I missing something?


'Life is what happens to you while you are busy making other plans' John W. Lennon 1940-1980
 
[3eyes]As Murphy already said:
[blue]If everything runs smoothly you must have overlooked something![/blue]
So before you spend lots of time in finding out why you don't get the procs:
The AfterUpdate analogon in Word forms is the "_Change()" event, i.e.
Code:
Sub yourcombo_Change()
...
End Sub
will be fired when you select anything from your combo box.

The Click event for a button is also a _Click() event in Word:
Code:
Sub yourbutton_Click()
...
End Sub
will be fired by a button click. (_DblClick() should be a double clikc event then)
Try doble clicking on your form - will this bring you to form code? If yes just enter your code there. If not, try with Alt+F11 and enter your code.
Must be some strange options set. Check tools-options in VB Editor...

BTW: Your no pain at all - you just found some Word behaviour I didn't know yet. So I also learned from you. Let me know about the options...

Good luck,
Andy
 
I think I see what the problem is: I have used the forms tool that allows you to embed a control on the Word document instead of using the VB editor to create a form. the document 'fields' behave differently to the 'normal' form fields.
Many thanks for your help on this
regards
Alan

'Life is what happens to you while you are busy making other plans' John W. Lennon 1940-1980
 
Ah yeah! Now that was it - didn't think of that.
Glad you figured it out. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top