Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-30-2018, 02:40 AM
macropod's Avatar
macropod macropod is offline VBA to provide text string with specific formating based on Drop down list (content control) Windows 7 64bit VBA to provide text string with specific formating based on Drop down list (content control) Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
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 gmayor View Post
Youi cannot format a content control dropdown list in this manner.
Au contraire, assuming the content control is given the tag 'Dropdown' :
Code:
Private Sub Document_ContentControlOnExit(ByVal CCtrl As ContentControl, Cancel As Boolean)
Application.ScreenUpdating = False
Dim strTxt As String, Rng As Range
With CCtrl
  If .Tag <> "Dropdown" Then Exit Sub
  If .ShowingPlaceholderText = True Then
    .Range.Font.StrikeThrough = False
    .Range.Font.Bold = False
    Exit Sub
  End If
  strTxt = .Range.Text
  If InStr(strTxt, "\") > 0 Then Exit Sub
  .Type = wdContentControlRichText
  .Range.Font.StrikeThrough = False
  .Range.Font.Bold = False
  With .Range
    .Text = "High\Significant\Low"
    .Font.StrikeThrough = True
    Set Rng = .Duplicate
    With Rng
      .End = .Start + InStr(.Text, "\")
      .Start = .End - 1
      .Font.StrikeThrough = False
    End With
    Set Rng = .Duplicate
    With Rng
      .End = .Start + InStrRev(.Text, "\")
      .Start = .End - 1
      .Font.StrikeThrough = False
    End With
    Set Rng = .Duplicate
    With Rng
      .Start = .Start + InStr(.Text, strTxt) - 1
      If InStr(.Text, "\") > 1 Then .End = .Start + InStr(.Text, "\") - 1
      .Font.StrikeThrough = False
      .Font.Bold = True
    End With
  End With
  .Type = wdContentControlDropdownList
End With
End Sub

__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]

Last edited by macropod; 07-30-2018 at 03:20 AM. Reason: Updated code
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA to provide text string with specific formating based on Drop down list (content control) Insert Rich Text Content Control in specific position, Word 2013 VBA LaurenM Word VBA 13 12-01-2017 02:07 AM
VBA to provide text string with specific formating based on Drop down list (content control) Export Word Drop-Down Content Control to Excel Specific Sheet nolanthomas32 Word VBA 4 09-19-2017 06:25 AM
VBA to provide text string with specific formating based on Drop down list (content control) How to get a Drop Down List Content Control box to fill in other areas snips1982 Word 2 03-22-2017 03:37 AM
VBA to provide text string with specific formating based on Drop down list (content control) How do I add selection of multi line content control list to specific table cell Dudlee Word VBA 1 09-20-2016 04:58 PM
Word 2010 Content Control help - Combo Boxes vs Drop Down List proghy Word 1 09-16-2014 02:01 PM

Other Forums: Access Forums

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


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