none
How to know if a text box has more thant one text line RRS feed

  • Question

  • Hi all

    I need to know if a text box in a word document has been fill with more than one text line, in order to change the size of the text box font.

    I'm using VBA automating Word 12.0 (Office 2007)....

    ActiveDocument.Shapes("tb_CLIENTE").TextFrame.TextRange.Text = "Someone with a long name..." 

    I haven't find a property that gives me tthis information something like:

    shapes ("xxx").textframe.text.rowcount   would be nice....

    The shapes ("xxx").textframe.Overflowing property returns True in almost every text box even with no text.... Didn't quite understand why...

    Any help would be apreciated.

    João


    Monday, March 11, 2013 2:34 PM

Answers

  • You can use code like:

    With ActiveDocument.Shapes(1).TextFrame.TextRange
      If .Characters.First.Information(wdVerticalPositionRelativeToPage) <> _
      .Characters.Last.Information(wdVerticalPositionRelativeToPage) Then _
      MsgBox "Text spans multiple lines"
    End With

    Cheers
    Paul Edstein
    [MS MVP - Word]

    Tuesday, March 12, 2013 3:58 AM

All replies

  • You can use code like:

    With ActiveDocument.Shapes(1).TextFrame.TextRange
      If .Characters.First.Information(wdVerticalPositionRelativeToPage) <> _
      .Characters.Last.Information(wdVerticalPositionRelativeToPage) Then _
      MsgBox "Text spans multiple lines"
    End With

    Cheers
    Paul Edstein
    [MS MVP - Word]

    Tuesday, March 12, 2013 3:58 AM
  • Paul,

    You're the best !!

    Thank you very much.

    Best regards

    João

    Tuesday, March 12, 2013 9:20 PM