Share via

Selecting text frames in Word 2010

Anonymous
2015-11-08T12:49:53+00:00

Hi all,

I've spent some time looking for an answer to this but loosing hope now .....

I have a songbook with a dozen or so pages.  Each page has around half a dozen chord charts for guitar.  Each chord chart comprises several graphical objects (grouped) and a text box with the chord name (using home>Editing>Selection pane the box is identified as 'Text Box XXX').

SO - in total about half a dozen text boxes inside groups on each page.

Everything is OK except that, somehow, the text inside the the text box has been set to 24 point and is too big to be shown (so is invisible).  I need the text to be set to (about) 8 point.

I can select each chord box group individually, clicking inside again allows me to select the individual text frame.  If I manually stretch the frame then I can see the text and change it's size but it is a long process.

I'm not beyond doing a few 'recorded' macros but in recording mode it seems impossible to select objects.  I've also tries selecting everything and setting the font size but it seems not to select the text inside the text boxes.

Anyone got any bright ideas?

Bob

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

6 answers

Sort by: Most helpful
  1. Jay Freedman 207.7K Reputation points Volunteer Moderator
    2015-11-09T17:38:11+00:00

    Hi Bob,

    The reason for the runtime error you saw is that the msoGroup object doesn't have a TextFrame of its own; only the drawing objects inside the group can have that. I haven't experimented to see whether VBA can address a drawing object's TextFrame while it's still grouped; more likely, you would have to ungroup the objects, change the size in the TextFrame, and regroup. That can be hard to program, but may be easier to do manually where you can see what's happening in the document.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2015-11-09T09:42:36+00:00

    Hi Jay ...

    I've found out a bit more about the object - it's actually a drawing imported from a Google Doc .... not sure if that helps or not.

    Following your instructions 

    ?ActiveDocument.Shapes(1).Type gave me the response 6

    I couldn't locate 6 in the Object Browser but MSDN suggests that it's a group

    https://msdn.microsoft.com/en-us/library/aa432678%28v=office.12%29.aspx?f=255&MSPPError=-2147217396

    (if I'm reading that right?

    Changing the macro to:

    Sub ResizeTextboxText()

        Dim tbox As Shape

        For Each tbox In ActiveDocument.Shapes

            If tbox.Type = msoGroup Then

                tbox.TextFrame.TextRange.Font.Size = 4

            End If

        Next

    End Sub

    resulted in the runtime error 5917 "This Object does not support attached text".

    You've been brilliant and I have certainly learnt a lot ... I'm thinking that the best way forward now is to simply redraw the graphics - many are repetitive so I'd imagine that there will be only a dozen or so to do.

    I had thought that Word might allow me to select multiple text frames but it does seem to be quite a task!

    Bob

    Was this answer helpful?

    0 comments No comments
  3. Jay Freedman 207.7K Reputation points Volunteer Moderator
    2015-11-09T01:06:32+00:00

    The most likely reason nothing happens is that what you're calling a "text box" is not what Word considers to be a "text box". For example, if you insert a rectangle from the Shapes gallery and give it a thin outline (or no outline) and no fill, it will look like a text box; you can add text inside it and move it around, and it will mostly behave like a text box. However, the statement If tbox.Type = msoTextBox Then in the macro will say "no, that isn't a real text box, because its Type is msoAutoShape" so the size statement won't execute.

    To find out what you really have is a little complicated, but not difficult:

    • In the macro editor, press Ctrl+G to open the Immediate window.
    • Type or paste this into that window and press Enter: ?ActiveDocument.Shapes(1).Type
    • A number will appear on the next line. If it's the number 1, then replace msoTextBox in the macro with msoAutoShape. (The number 17 corresponds to msoTextBox, and you already know that's not it.) If it's another number, continue to the next step.
    • Close the Immediate window and then press F2 to open the Object Browser.
    • Type the word msoShapeType (the name of the batch of values of Type) in the search box and press Enter. The list of value names appears in the right side; click any one of them to see its numeric value. Locate the one whose value matches what you saw in the Immediate window.

    • When you find the matching value, put its name into the If statement in the macro.

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2015-11-08T16:52:33+00:00

    Hi Jay,

    thank you so much for getting back - really appreciated.

    I had a quick go and nothing seemed to happen so I modified it a bit (for testing) and ended up with:

    Sub ResizeTextboxText()

    counter = 1

        Dim tbox As Shape

        For Each tbox In ActiveDocument.Shapes

            If tbox.Type = msoTextBox Then

                tbox.TextFrame.TextRange.Font.Size = 4

            End If

        counter = counter + 1

        Next

    Reply = MsgBox(counter, vbOKOnly) = vbOK

    End Sub

    The counter returned 80 which is about the same number of boxes I have so that seems to be good.  The text inside the text boxes still seems to be Arial 24 point (Bold) though.

    Does the text inside the frame need to be selected first? or the frame become active?

    Bob

    Was this answer helpful?

    0 comments No comments
  5. Jay Freedman 207.7K Reputation points Volunteer Moderator
    2015-11-08T16:11:54+00:00

    Yeah, the macro recorder is completely lame when it comes to graphics (and Word considers a text box to be a kind of graphic). The macro you need has to be written from scratch. Fortunately, it's simple:

    Sub ResizeTextboxText()

        Dim tbox As Shape

        For Each tbox In ActiveDocument.Shapes

            If tbox.Type = msoTextBox Then

                tbox.TextFrame.TextRange.Font.Size = 8

            End If

        Next

    End Sub

    If you need a different size, change the number 8 to something else. The font size is settable in 0.5 point increments.

    Was this answer helpful?

    0 comments No comments