#  Other Applications & Softwares  > Word Formatting & General >  > [SOLVED] Is Conditional formatting possible for dropdown list in word ?

## wmurugan

Hi,

I am desiging a MS word form using the legacy tool feature. My problem is as follows;
I'm trying to incorporate conditional formatting similar to what we can do in excel.Threre is a drop down form field with three choices , let say Red,Green and yellow. When these choices are slected i want the background to change/shaded appropritely. i.e. color red when the user selection is "red" from the dropdown and so on. 
So far i have seen only VBA codes to change the fonts only but not the one to change the background color. 

So is this possible to change the background color ?

below is the code for to change the font color,but it is not refreshing ...



```
Please Login or Register  to view this content.
```


any help appreciated.

Thanks,

----------


## macropod

Hi wmurgan,

Have you attached the macro to the calling formfield's 'on exit' property?
Does the dropdown have an internal bookmark named "Dropdown2" (which is what the code refers to)?
Are you exiting the dropdown?
Assuming the answer to all three questions is yes, you could use:



```
Please Login or Register  to view this content.
```

----------


## wmurugan

Hi Paul,

Thanks for your quick help.I wasn't sure if the shading option was available.Great tip!.
For some reason it's not working properley for me. Please see the attached doc.What i am doing wrong here?  Ideally i would want the shading including the font color to change per the user input from the dropdown without having to save the file and re-open to see the change. Hopefully this makes sense.Appreciate the help once again.

Regards,
Wmurugan

----------


## macropod

Hi Wmurugan,

It works fine for me. You need to apply forms protection and, preferably, turn off formfield shading (via the legacy tools button on the Developer tab).

PS: For whatever reason you've formatted the formfield as bright green. If you're going to be changing the background shading, I'd suggest changing the font colours at the same time, to provide more contrast.

----------


## wmurugan

Hi Paul,

Thanks once again. Yes the shading works with the click of "Tab".The other problem that i am trying to solve is - the dropdown input letter font color to match the background/shading color. Since those letters are for user input only. So for red shading the letter"r" font color should also be red and so on for the rest of the selection letters.

Apart from that can you check the attached doc. and let me know why i'm not able to replicate the shading in multiple dropdown list.

Appreciate your help.

Regards,
Wmurugan

----------


## macropod

See attached.

----------


## wmurugan

Hi Paul,

Thanks a lot. It works fine in your attached document. Did you change any object property to remove the grey font background. See the attached document. I'm unable to replicate the same in my document. Also i'm getting the "runtime error 5941" the requested member of the collection doesn't exist. I have another legacy dropdown field which is simple dropdown list without any color format, for which i removed the bookmark and there is no macro attached to it.
So basically, 1) What object properties do i need to change to remove the grey background (see the attached doc.)
2) how to handle the runtime error 5941.

Appreciate the help.

Regards,
wmurugan

----------


## wmurugan

Hi Paul,

I found that the solution to my first question wrt grey background. All i need to do was to trun off the "Form field" shading in the legacy tool. Now i'm not sure how to handle the error code.

Thanks

----------


## macropod

Try changing the Document_Open sub to:



```
Please Login or Register  to view this content.
```

----------


## wmurugan

Hi,

Not sure what is wrong. Getting the same Runtime error 5941 'The requested member of the collection doesn't exist'.

Attached is the snapshot of the code when i try to debug. Thanks for your continued help.

Regards,
Wmurugan

----------


## macropod

Hmm, I'm not getting an error with either of the two previous implementations. Give this a try:



```
Please Login or Register  to view this content.
```

----------


## wmurugan

Hi Paul,

Thanks a lot. It now seems to have fixed the runtime error 5941. But apparently there is new runtime error 4248-" This command is not availble becuse no document is open". This happens when the new user tries to open the word document after clicking the enabling editing in the protected view. Is there way to handle this with error handler similar to this;




```
Please Login or Register  to view this content.
```


apprecite your help greatly.

Regards,

----------


## wmurugan

Hi Paul,

I fixed the problem with the following code below;




```
Please Login or Register  to view this content.
```


Thanks a bunch for answering my repeated questions. Appreciate all your help.

Regards,
wmurugan

----------


## Cutter

@ wmurugan 

Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED.  I'll do that for you now but please keep in mind for your future threads that Rule #9 requires you to do that yourself.  If your problem has not been solved you can use Thread Tools (located above your first post) and choose "Mark this thread as unsolved".
Thanks.

Also, as a new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

----------

