Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-13-2019, 03:03 PM
therexjones therexjones is offline Bold Content Control Placeholder Windows 10 Bold Content Control Placeholder Office 2016
Novice
Bold Content Control Placeholder
 
Join Date: Sep 2018
Posts: 6
therexjones is on a distinguished road
Default Bold Content Control Placeholder

I have a content control on a template, which has the placeholder text in bold. I used design mode to get the text into bold in the first place.

I am trying to create a code that will change the placeholder text (based on options in a userform), but retain the bold formatting.



The code below changed the text, but the bold formatting is lost. What do I need to add to control the formatting?

Code:
Sub ChangePlaceholder()

Dim objCC As ContentControl
 
Set objCC = ActiveDocument.SelectContentControlsByTag("myContentControl").Item(1)
    objCC.SetPlaceholderText , , "New Placeholder Text"

End Sub
Reply With Quote
  #2  
Old 10-13-2019, 11:25 PM
gmayor's Avatar
gmayor gmayor is offline Bold Content Control Placeholder Windows 10 Bold Content Control Placeholder Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Add the line
objCC.Range.Font.Bold = True
before
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 10-14-2019, 06:08 AM
gmaxey gmaxey is offline Bold Content Control Placeholder Windows 10 Bold Content Control Placeholder Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,422
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Graham's method may work but it will effect the typed text as well. If you want the PHT to be bold and the typed text normal then you could set the PHT to saved building block entry of the PHT with block font) e.g.,


Code:
If A Then
  ActiveDocument.ContentControls(1).SetPlaceholderText ThisDocument.AttachedTemplate.BuildingBlockEntries("PHT1")
Else
  ActiveDocument.ContentControls(1).SetPlaceholderText ThisDocument.AttachedTemplate.BuildingBlockEntries("PHT2")
End If
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #4  
Old 10-14-2019, 09:14 PM
gmayor's Avatar
gmayor gmayor is offline Bold Content Control Placeholder Windows 10 Bold Content Control Placeholder Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Quote:
Originally Posted by gmaxey View Post
Graham's method may work but it will effect the typed text as well
Actually it doesn't appear to in my tests (admittedly not exhaustive), but if you remove the text entered into the control it does not revert to showing the bold placeholder.

You could get round that with a macro

Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
    If ContentControl.Title = "myContentControl" Then
        If ContentControl.ShowingPlaceholderText = True Then
            ContentControl.Range.Font.Bold = True
        End If
    End If
End Sub
You could add an Else branch to set the font to normal weight if required.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #5  
Old 10-15-2019, 05:34 AM
gmaxey gmaxey is offline Bold Content Control Placeholder Windows 10 Bold Content Control Placeholder Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,422
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Graham, you are right. Yesterday, I could have sworn after running your bit a code on a CC that after I typed in it, the text was bold. Not the case today. Thanks.
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #6  
Old 10-18-2019, 09:09 PM
therexjones therexjones is offline Bold Content Control Placeholder Windows 10 Bold Content Control Placeholder Office 2019
Novice
Bold Content Control Placeholder
 
Join Date: Sep 2018
Posts: 6
therexjones is on a distinguished road
Default

Thanks, guys.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bold Content Control Placeholder Partial bold formatting of content control kevinbradley57 Word 5 05-21-2018 09:22 PM
Bold Content Control Placeholder Don't Print Content Control Placeholder Text vera Word VBA 3 07-01-2016 01:57 PM
How to set the Content Control placeholder default text dsimon14 Word VBA 3 03-27-2015 07:15 AM
Bold Content Control Placeholder Deleting a table from a content control -- preserving the content control BrainSlugs83 Word Tables 8 11-14-2013 03:06 AM
Bold Content Control Placeholder SlideMaster: Date Placeholder, Footer Placeholder, Slide Number Placeholder? tinfanide PowerPoint 1 04-05-2013 10:37 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:23 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