How to format the text of entire text box?

S

src

Hi there,

I'm trying to format an entire text box in one shot.

Manually,
1) I select the text box
2) from toolbar choose Font, Size, Bold etc.

and it's applied to all the text in the whole box immediately.

Recording this action gives:

Sub formatTextBox3()
Selection.Font.Name = "Arial"
Selection.Font.Size = 12
Selection.Font.Bold = wdToggle
End Sub

But, changing those values then selecting the text box and running the
macro does nothing.

I changed the code to automatically select the text box:

Sub formatTextBox3()
ActiveDocument.Shapes(1).Select
Selection.Font.Name = "Arial"
Selection.Font.Size = 12
Selection.Font.Bold = wdToggle
End Sub

But to no avail. Can anyone help?

Thanks!
 
J

Jay Freedman

I don't see that behavior, in either Word 2003 or 2007. Running the
code you showed from the recorder, when the textbox is selected, does
change the formatting of the textbox's contents. I don't know why
yours isn't working.

Since it's a textbox, though, you could modify the code like this to
dig deeper into the textbox object:

With ActiveDocument.Shapes(1).TextFrame.TextRange.Font
.Name = "Arial"
.Size = 12
.Bold = wdToggle
End With
 
S

src

That worked perfect!
Thanks!

I'm using Word 2003, and originally the text box was dragged out of a
Drawing Canvas, so I'm not sure if that affects how it operates.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top