Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-14-2018, 06:09 PM
Instructionalhelp Instructionalhelp is offline Help with Colour Coding drop downs. Mac OS X Help with Colour Coding drop downs. Office 2016 for Mac
Novice
Help with Colour Coding drop downs.
 
Join Date: Mar 2018
Posts: 6
Instructionalhelp is on a distinguished road
Default Help with Colour Coding drop downs.

Hi,



I have created a form with form fields and I require that when ever I select a different option from the AON Type field that everything Orange change Colour


EG Safety Notice- Yellow
Sop Update - Green
Advisory Bulletin - Dark Grey
AON - Training Update - Pink

I really have no idea on how to start this and would appreciate some help / advice.
Attached Files
File Type: docx test.docx (48.8 KB, 9 views)
Reply With Quote
  #2  
Old 03-14-2018, 08:57 PM
macropod's Avatar
macropod macropod is offline Help with Colour Coding drop downs. Windows 7 64bit Help with Colour Coding drop downs. Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Instructionalhelp:
Kindly -
1. Don't post the same question multiple times;
2. Resurrect ancient threads on unrelated topics; and
3. Hijack existing threads on unrelated topics.
I have deleted one post to which 1 & 2 apply and moved the post to which 1 & 3 apply to its own thread.

As for the problem itself, see the formfield demonstration in the attachment at: https://www.msofficeforums.com/word-...html#post47254
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 03-14-2018, 09:43 PM
Instructionalhelp Instructionalhelp is offline Help with Colour Coding drop downs. Mac OS X Help with Colour Coding drop downs. Office 2016 for Mac
Novice
Help with Colour Coding drop downs.
 
Join Date: Mar 2018
Posts: 6
Instructionalhelp is on a distinguished road
Default

Thank you for your advice and assistance.

I have tried this but still seem to be having no luck.

Kind regards
Attached Files
File Type: docx test.docx (265.5 KB, 7 views)
Reply With Quote
  #4  
Old 03-14-2018, 09:46 PM
macropod's Avatar
macropod macropod is offline Help with Colour Coding drop downs. Windows 7 64bit Help with Colour Coding drop downs. Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Your attachment is a .docx file. Files in the .docx format cannot contain macros, so it is impossible for me to see what steps you've taken to implement the solution I pointed you to.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 03-14-2018, 09:52 PM
Instructionalhelp Instructionalhelp is offline Help with Colour Coding drop downs. Mac OS X Help with Colour Coding drop downs. Office 2016 for Mac
Novice
Help with Colour Coding drop downs.
 
Join Date: Mar 2018
Posts: 6
Instructionalhelp is on a distinguished road
Default

Apologies for that I attached incorrect file. Here we go. I have been trying for days to get it going so I have so many files saved now
Attached Files
File Type: docm test.docm (264.3 KB, 8 views)
Reply With Quote
  #6  
Old 03-15-2018, 02:05 PM
macropod's Avatar
macropod macropod is offline Help with Colour Coding drop downs. Windows 7 64bit Help with Colour Coding drop downs. Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

There is no code in your latest attachment, either, so it is impossible for me to see what steps you've taken to implement the solution I pointed you to.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 03-15-2018, 03:40 PM
Instructionalhelp Instructionalhelp is offline Help with Colour Coding drop downs. Mac OS X Help with Colour Coding drop downs. Office 2016 for Mac
Novice
Help with Colour Coding drop downs.
 
Join Date: Mar 2018
Posts: 6
Instructionalhelp is on a distinguished road
Default

I have just checked the file I sent to you and I can see the macro and the code when I open it and go to the developer tab and macros.

Please see a copy and paste of what I see.


End Sub
Option Explicit
Dim i As Long

Private Sub Document_Open()
ActiveDocument.Bookmarks("ColourDropDown").Range.S elect
Call Index
End Sub

Sub Index()
i = Replace(Selection.FormFields(1).Range.Bookmarks(1) .Name, "ColourDropDown", "")
End Sub

Sub ColorDropDown()
Dim sText As String, oFld As FormField
With ActiveDocument
Set oFld = .FormFields("Dropdown" & i)
sText = oFld.Result
If .ProtectionType <> wdNoProtection Then .Unprotect Password:=""
With oFld.Range
Select Case sText
Case Is = "SOP UPDATE" 'green
.Font.Color = wdColorBrightGreen
.Shading.BackgroundPatternColor = wdColorBrightGreen
Case Is = "SAFETY NOTICE" 'yellow
.Font.Color = wdColorYellow
.Shading.BackgroundPatternColor = wdColorYellow
Case Is = "TRAINING UPDATE" 'pink
.Font.Color = wdColorRed
.Shading.BackgroundPatternColor = wdColorRed
Case Is = "ADVISORY BULLETIN" 'grey
.Font.Color = wdColorRed
.Shading.BackgroundPatternColor = wdColorRed
End Select
End With
.Protect Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=""
End With
End Sub
Reply With Quote
  #8  
Old 03-15-2018, 05:37 PM
macropod's Avatar
macropod macropod is offline Help with Colour Coding drop downs. Windows 7 64bit Help with Colour Coding drop downs. Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by Instructionalhelp View Post
I have just checked the file I sent to you and I can see the macro and the code when I open it and go to the developer tab and macros.
All that likely means is that you've added the code to the document's template, not to the document itself, and your attachment doesn't show how, it at all, you're invoking the ColorDropDown macro.

PS: When posting code, please use the code tags, indicated by the # button on the posting menu. Without them, your code loses much of whatever structure it had.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #9  
Old 03-15-2018, 05:45 PM
Instructionalhelp Instructionalhelp is offline Help with Colour Coding drop downs. Mac OS X Help with Colour Coding drop downs. Office 2016 for Mac
Novice
Help with Colour Coding drop downs.
 
Join Date: Mar 2018
Posts: 6
Instructionalhelp is on a distinguished road
Default

Thank you for this.

Please find attached file and hopefully macro is attached to document and not template.

Kind regards
Attached Files
File Type: docm test.docm (270.2 KB, 8 views)
Reply With Quote
  #10  
Old 03-15-2018, 06:34 PM
macropod's Avatar
macropod macropod is offline Help with Colour Coding drop downs. Windows 7 64bit Help with Colour Coding drop downs. Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Your code doesn't make much sense to me.

There's an obvious error with 'End Sub' appearing before 'Option Explicit'.

Then you have a Document_Open macro that selects the 'ColourDropDown' bookmark and then calls an 'Index' macro that tries to populate a variable 'i' with whatever appears in the corresponding formfield's internal bookmark after 'ColourDropDown'. A coding error there means the code falls over that that point. If it worked, 'i' would always be 0, since the formfield's name is the same as the 'ColourDropDown' bookmark itself. So what is the point of the 'i' variable?

If the above worked, you would then have your formfield call the 'ColorDropDown' macro, whose code looks for a formfield named '"DropDown" & i' which, if anything, would always evaluate to 'DropDown0'. But no such formfield exists - the dropdown formfield's name is only ever 'ColourDropDown' and no other formfield with a name like '"DropDown" & i' exists in the document.

Finally, even if you resolve all of the above, your code would set the Dropdown selection's font and background to the same colour, effectively making the text invisible.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #11  
Old 03-15-2018, 06:47 PM
Instructionalhelp Instructionalhelp is offline Help with Colour Coding drop downs. Mac OS X Help with Colour Coding drop downs. Office 2016 for Mac
Novice
Help with Colour Coding drop downs.
 
Join Date: Mar 2018
Posts: 6
Instructionalhelp is on a distinguished road
Default

Sadly I am still having no luck but I may be totally misunderstanding what you are saying.

Should it be this hard?
Attached Files
File Type: docm test.docm (270.0 KB, 6 views)
Reply With Quote
  #12  
Old 03-15-2018, 10:35 PM
macropod's Avatar
macropod macropod is offline Help with Colour Coding drop downs. Windows 7 64bit Help with Colour Coding drop downs. Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

It really isn't hard if you don't try to be unnecessarily creative and take care with what you're doing. See attached. Compare my code to yours...
Attached Files
File Type: docm Test.docm (271.6 KB, 12 views)
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Drop Downs Suray1911 Excel 1 09-29-2015 10:31 PM
Help with Colour Coding drop downs. Excel 2013 Project Timeline - colour coding data labels MicrosoftNovice2015 Excel 1 09-15-2015 02:16 PM
Help with Colour Coding drop downs. field shading for drop downs rbd50 Mail Merge 3 03-31-2015 09:52 PM
Help with Colour Coding drop downs. Drop-Downs: Run Macro on Exit Andrew H Word VBA 15 11-16-2012 08:34 AM
Help with Colour Coding drop downs. Please help me with drop downs in Excel 2010 mhays Excel 6 01-16-2012 09:29 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:56 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft