Unbolding Text in a text box

Chris Macro

Well-known Member
Joined
Nov 2, 2011
Messages
1,345
Office Version
  1. 365
Platform
  1. Windows
I have a string "Comments: " inside a comment textbox and I want to have just "Comments" bolded out in the string and everything else to be normal font. So the end result would look like "Comments: These are my comments". My problem is that through the following two macros that my textbox is bolding the entire string of words instead of the specific one I want. Any ideas on how to fix this?

Userform 1:
<font face=Calibri><SPAN style="color:#007F00">'Comments</SPAN><br>    ActiveSheet.Shapes("Textbox 2").TextFrame.Characters.Text = "Comments: " & Comments<br>    <SPAN style="color:#007F00">'Bold "Comments:"</SPAN><br>        ActiveSheet.Shapes("Textbox 2").OLEFormat.Object.Characters(1, 8).Font.FontStyle = "Bold"</FONT>

Macro 1:
<font face=Calibri><SPAN style="color:#00007F">Sub</SPAN> Clear_Sheet()<br><br><SPAN style="color:#00007F">With</SPAN> Sheet1<br><br>    <SPAN style="color:#007F00">'Clear Comment Box</SPAN><br>        .Shapes("Textbox 2").TextFrame.Characters.Text = "Comments: "<br>        <SPAN style="color:#007F00">'Bold "Comments:"</SPAN><br>            .Shapes("Textbox 2").OLEFormat.Object.Font.FontStyle = "Normal"<br>            .Shapes("Textbox 2").OLEFormat.Object.Characters(1, 8).Font.FontStyle = "Bold"<br>    <br>    <SPAN style="color:#007F00">'Clear Data</SPAN><br>        .Range("B12:I2000").ClearContents<br>        <br>    <SPAN style="color:#007F00">'Clear Header Data</SPAN><br>      .Range("C2:C5").ClearContents<br><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br></FONT>
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
This worked for me with a TextBox from the Drawing Toolbar:

Code:
Sub BoldComments()
    Const Comments As String = "These are my comments"
    ActiveSheet.Shapes("Textbox 2").TextFrame.Characters.Text = "Comments: " & Comments
'   Bold "Comments:"
    ActiveSheet.Shapes("Textbox 2").OLEFormat.Object.Characters(1, 9).Font.FontStyle = "Bold"
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,222
Messages
6,123,706
Members
449,118
Latest member
MichealRed

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top