Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 01-11-2024, 01:41 AM
WordVB WordVB is offline Bold certain parts of bookmarks text code help Windows 11 Bold certain parts of bookmarks text code help Office 2016
Novice
Bold certain parts of bookmarks text code help
 
Join Date: Jan 2024
Location: Ireland
Posts: 12
WordVB is on a distinguished road
Default Bold certain parts of bookmarks text code help

Hi All,



I am looking for some ideas please. This is the first time I am using VB so still am very fresh here. I am working on a simple word document, where the front page is used to check boxes and based on true false values it inserts texts in bookmark fields further down the document. Managed to get all with the help of this Forum but got stuck with one step. The text I am inserting looks like below:

"Title

First line"



What I want to do is to make word "Title" bold and leave the rest non-bold.

Option Explicit
Dim oRng As Range
Dim oBM As Bookmark


Private Sub CheckBox1_Click()
If Me.CheckBox1.Value = True Then
Set oRng = ActiveDocument.Bookmarks("Text1").Range
oRng.Text = "Title" & Chr(10) & "First line"
ActiveDocument.Bookmarks.Add "Text1", oRng
With oRng.Font
.Bold = True
End With
Else: Set oRng = ActiveDocument.Bookmarks("Text1").Range
oRng.Text = "Blank"
ActiveDocument.Bookmarks.Add "Text1", oRng
With oRng.Font
.Bold = False
End With
End If
End Sub

It could do something with selecting the range but I am unsure how.

Any thoughts would be greatly appreciated.
Reply With Quote
 

Tags
bold header

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bold certain parts of bookmarks text code help How to code a Find&Replace macro to remove a tab and bold the entire para Frogoogue Word VBA 4 05-30-2022 09:15 AM
Bold certain parts of bookmarks text code help bold (or unbold) section of text instead of bold toggling Burt Word 6 04-06-2019 09:09 AM
Bold certain parts of bookmarks text code help Text in #1 is made bold, rest of the document is edited, text in #1 is now not bold footer-assistance Word 1 06-29-2015 03:49 AM
Bold certain parts of bookmarks text code help Not Bold text but it comes up bold Pluviophile Word 7 10-22-2013 10:29 AM
Bold certain parts of bookmarks text code help VBA code to extract specific bookmarks from multiple word files Rattykins Word VBA 4 06-27-2012 10:02 PM

Other Forums: Access Forums

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