Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-26-2018, 05:38 PM
DebA DebA is offline Table with content control drop down - change font Windows 10 Table with content control drop down - change font Office 2013
Novice
Table with content control drop down - change font
 
Join Date: Apr 2018
Posts: 2
DebA is on a distinguished road
Default Table with content control drop down - change font

I have created a table that is going to be completed by users within a geographically disperse region. one of the tables is Action Required - title ACTION
There are three options
Urgent 2 days - value: URGENT
Follow up 7 days - value : FOLLOW
Information only / reading - value : INFORMATION

when the person selects the option I am wanting the font colour to change
urgent - red


follow - orange
Information - green

I have been trying my best to understand and use previous threads. and I have used the following in VBA ThisDocument I have saved the document as macro enabled. nothing is changing. What am I doing wrong ????? ps this is my first time at using the msoffice forum

Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
If ContentControl.Title = "ACTION" Then
With ContentControl.Range
Select Case .Text
Case "URGENT"
.Cells(1).Font.Color = wdColorRed
Case "FOLLOW"
.Cells(1).Font.Color = wdColorOrange
Case "INFORMATION"
.Cells(1).Font.Color = wdColorGreen
End Select
End With
End If
End Sub
Reply With Quote
  #2  
Old 04-27-2018, 06:38 PM
Guessed's Avatar
Guessed Guessed is offline Table with content control drop down - change font Windows 10 Table with content control drop down - change font Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,967
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

You were almost there. Two things:
- Capitalisation is important. If you don't match the same capitalisation then your code would fail. I've added the UCase to your code to avoid this problem
- You need to specify the RANGE where you want to colour the font. This code now colours the entire cell's range but you may have been happy just doing the range of the Content Control (in which case .Font.Color = wdColorRed would have been enough
Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
  If UCase(ContentControl.Title) = "ACTION" Then
    With ContentControl.Range
      Select Case UCase(.Text)
      Case "URGENT"
        .Cells(1).Range.Font.Color = wdColorRed
      Case "FOLLOW"
        .Cells(1).Range.Font.Color = wdColorOrange
      Case "INFORMATION"
        .Cells(1).Range.Font.Color = wdColorGreen
      End Select
    End With
  End If
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #3  
Old 04-29-2018, 07:20 PM
DebA DebA is offline Table with content control drop down - change font Windows 10 Table with content control drop down - change font Office 2013
Novice
Table with content control drop down - change font
 
Join Date: Apr 2018
Posts: 2
DebA is on a distinguished road
Default

I don't know what I am doing wrong. Sorry Andrew.

I copied and pasted your suggestion and it is not changing for me. I even tried to add a new line in the table and start from fresh.

Title : ACTION
Tag : ACTION
Bounding box
display name
URGENT 2 Days Value URGENT
FOLLOW 7 Days Value FOLLOW
INFORMATION Value INFORMATION

Then I added the script

When I go into "design mode" it is showing:
ACTION choose an item ACTION

I really don't know what I have done wrong.

Thank you for your assistance it is really appreciated. ps - love the Larson image.
Reply With Quote
  #4  
Old 04-29-2018, 09:07 PM
Guessed's Avatar
Guessed Guessed is offline Table with content control drop down - change font Windows 10 Table with content control drop down - change font Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,967
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

In that case, add the following line as indicated to get an idea on where it is going wrong
Code:
  If UCase(ContentControl.Title) = "ACTION" Then
      MsgBox "The value which should be in the Case is: " & UCase(.Text)
    With ContentControl.Range
When you leave the content control, you will see a dialog appear on screen. If you don't, then you know either the macro didn't run or the title of the Content Control isn't 'Action'

If you still can't work it out, post a sample document with the macro.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Table with content control drop down - change font How to get a Drop Down List Content Control box to fill in other areas snips1982 Word 2 03-22-2017 03:37 AM
Populate Drop-Down Content Control from CustomXMLPart added to the Document KhmerBoi1 Word VBA 0 05-11-2016 01:10 PM
Table with content control drop down - change font Is there a way to anchor drop-down content control boxes so entering text doesn't change formatting? TzarChasm Word 7 04-14-2016 06:28 PM
Word drop-down content control dependent display issue vvcat Word 6 02-03-2015 11:20 PM
Table with content control drop down - change font Deleting a table from a content control -- preserving the content control BrainSlugs83 Word Tables 8 11-14-2013 03:06 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:00 AM.


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