Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    Lounger
    Join Date
    Jan 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    35
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Find & Replace in All Text Boxes (2002)

    I have had a long-standing problem with Word. I have a number of documents that use a large number of Callouts to explain pictures. Now I want to change the font & size of all the text in these text boxes. But a search & replace never finds anything in my textboxes/callouts. This is true even if I start the search in the text box itself. Is there any way to do what I want in Word, short of manually?

  2. #2
    5 Star Lounger
    Join Date
    May 2001
    Location
    Stuttgart, Baden-W, Germany
    Posts
    931
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Find & Replace in All Text Boxes (2002)

    Could you use a style for the text in all your callouts? Then changing the style would take care of the font and size in all of them.

    The macro below assigns the style "Callout" (which you would have to define before running the macro) to the text in all the text boxes and callouts in the main story range:
    <pre>Sub AssignCalloutStyle()
    Dim myShape As Shape
    On Error Resume Next
    For Each myShape In ActiveDocument.Shapes
    myShape.TextFrame.TextRange.Style = "Callout"
    Next myShape
    End Sub</pre>


    > But a search & replace never finds anything in my textboxes/callouts.

    This sounds funny ... In Word2000, I don't have problems to find text in callouts or textboxes. Things are more complicated if you search using a macro: you then have to cycle through all the StoryRanges.

    But what is missing (at least in Word2000) is a way to locate text boxes and callouts with Edit > GoTo.

    <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>Klaus

  3. #3
    Lounger
    Join Date
    Jan 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    35
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Find & Replace in All Text Boxes (2002)

    Thanks, that worked very well. I was even able to include a border in the definition of the Callout style, so the macro changed the border style. What it did not do, however, was change the line style of the line attached to the callout. I know how to do this manually, (Format.Autoshape etc). How do you do that programatically? Thanks.

  4. #4
    Silver Lounger
    Join Date
    Jan 2001
    Location
    West Long Branch, New Jersey, USA
    Posts
    1,921
    Thanks
    6
    Thanked 9 Times in 7 Posts

    Re: Find & Replace in All Text Boxes (2002)

    Klaus,

    Just curious about the statement
    myShape.TextFrame.TextRange.Style = "Callout"
    in your macro.

    myShape loops thru every shape in the main story. If I added a rectangle or a cirlce, I can't type in it directly as I can in ppt (this is for word 97) unless I right click the shape and choose Add Text. If I do this, is this in effect creating a TextFrame such that this rectangle would be chosen in the loop?

    When adding a callout or a text box, Word 97 assumes you want to add text so it gives you a para mark and you're ready to type. Not like a rectangle, star or other shapes, where you need to right click first.

    It just seemed from the syntax that the statement would choose any shape with a textframe. I wasn't sure if this would include those modified rectangles.

    So how would I just single out Callout shapes?

    Fred

  5. #5
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Find & Replace in All Text Boxes (2002)

    Hi,

    The following emendation to Klaus' code demonstrates how to do that:

    <pre>Sub AssignCalloutStyle()
    Dim myShape As Shape
    On Error Resume Next
    For Each myShape In ActiveDocument.Shapes
    If myShape.Type = msoCallout Then
    myShape.TextFrame.TextRange.Style = "Callout"
    myShape.Line.Style = msoLineThickBetweenThin
    End If
    Next myShape
    End Sub
    </pre>

    Note: I've chosen one of the "msoLine" constants randomly, there are a whole list of these available via code.
    Also note: I got lazy and therefore the above code is untested! <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

    Gary

  6. #6
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Find & Replace in All Text Boxes (2002)

    Fred,
    (I hope Klaus won't mind my answering your question)

    Yes you're right that by default these shapes do not contain textframes and that you are adding one when you choose to Add Text.

    See the previous post for the code statement to limit the changes to callouts only.

    You stay up late at night just thinking up these (good) questions, don't you? <img src=/S/laugh.gif border=0 alt=laugh width=15 height=15>

    Gary

  7. #7
    5 Star Lounger
    Join Date
    May 2001
    Location
    Stuttgart, Baden-W, Germany
    Posts
    931
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Find & Replace in All Text Boxes (2002)

    I must admit that I know next to nothing about (Auto)Shapes. I'd try to record the manual adjustment, then add the recorded modification to the macro (myShape.Adjustments.Item(1) = 0.25 or whatever).

    With true Callouts, I don't think you can change the width of the line independently of the width of the border (myShape.Line.Weight = 1.5).

    <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>Klaus

  8. #8
    5 Star Lounger
    Join Date
    May 2001
    Location
    Stuttgart, Baden-W, Germany
    Posts
    931
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Find & Replace in All Text Boxes (2002)

    Hi Gary,

    Glad you are helping me out ... This stuff is all new to me!

    With the callouts I tested, setting the line style didn't seem to make any difference. What is myShape.Line.Style = msoLineThickBetweenThin supposed to look like?

    Re Fred's question: I didn't know if the question refered to textboxes or callouts (from easson's last question, I guess it's AutoForms used as callouts), and even if I knew, I wouldn't know an easy way to loop just Shapes with some special attribute(s).
    "On Error Resume Next" was the lazy way out <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

    <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>Klaus

  9. #9
    Silver Lounger
    Join Date
    Jan 2001
    Location
    West Long Branch, New Jersey, USA
    Posts
    1,921
    Thanks
    6
    Thanked 9 Times in 7 Posts

    Re: Find & Replace in All Text Boxes (2002)

    Hi Gary,

    Thks for the refinement and answer.

    It wasn't that late here (US East Coast) when I posted the question. Besides, it helps me learn. But you got up real early to answer it. <img src=/S/evilgrin.gif border=0 alt=evilgrin width=15 height=15>

    BTW: what would the test on whether the shape is a callout have been if I only wanted one type of callouts as opposed to any of them? Is there some constant that says which specific shape it is?

    Just by coincidence, yesterday a friend was asking about text in AutoShapes as they're used in Excel. One of her clients has some drawings with text in AutoShapes. He does everything in Excel - even web page design. Anyway, the drawings were for a patent but the font size was too small to meet the European Patent Office's rqmts. So she has to redo all the text. The bad news is that Excel's styles don't apply to AutoShapes (at least not in 97) - the style box goes gray when you're in an Autoshape. The good news is that she can use the Format Painter to change one shape and then just paint the other shapes. Viva la difference!

    Fred

  10. #10
    5 Star Lounger
    Join Date
    May 2001
    Location
    Stuttgart, Baden-W, Germany
    Posts
    931
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Find & Replace in All Text Boxes (2002)

    Hi Fred,
    (I hope Gary won't mind my answering your question <img src=/S/wink.gif border=0 alt=wink width=15 height=15>)

    I guess if you were looking for only some special kind of Shape/Callout, you could remove the "On Error Resume Next", and use two nested Ifs:

    <pre> If myShape.Type = msoCallout Then
    If myShape.Callout.Type = msoCalloutTwo Then</pre>

    or
    <pre> If myShape.Type = msoAutoShape Then
    If myShape.AutoShapeType = msoShapeCloudCallout Then</pre>


    <img src=/S/2cents.gif border=0 alt=2cents width=15 height=15>My two cents from Euroland, Klaus

  11. #11
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Vienna, Wien, Austria
    Posts
    5,009
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Find & Replace in All Text Boxes (2002)

    Hi Fred
    <hr>It wasn't that late here (US East Coast)<hr>
    Your profile says your Time (UTC) Offset is 0 (i.e. UK & Ireland). Is that a "red herring" to keep us on our toes? (US East Coast is -5.)
    Gre

  12. #12
    Silver Lounger
    Join Date
    Jan 2001
    Location
    West Long Branch, New Jersey, USA
    Posts
    1,921
    Thanks
    6
    Thanked 9 Times in 7 Posts

    Re: Find & Replace in All Text Boxes (2002)

    Hi Unkamunka,

    You're right - I never changed my time offset when I registered. SO the default of 0 is what I had.

    I've changed that now. However, I'd bet that most people don't know what their offset is, let alone bother filling it in when registering.

    Fred

  13. #13
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Vienna, Wien, Austria
    Posts
    5,009
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Find & Replace in All Text Boxes (2002)

    Hi Fred

    Perhaps that's why the default is now "blank". The inference I drew was that filling it in is a halfway house: where, for whatever reason, posters don't want to be more precise about their geographic location. (I don't recall the option being available in the old Lounge.) I was surprised in how many instances the UTC is filled in, but then I only tend to check when I'm having trouble understanding - or am intrigued by - the poster's use of the English language.
    Gre

  14. #14
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Find & Replace in All Text Boxes (2002)

    Klaus,

    Just to confirm what I was too lazy to test the first time around <img src=/S/grin.gif border=0 alt=grin width=15 height=15> - as you say, setting the line style doesn't seem to make any difference - I can't find any way to make that work via code. This may just qualify as a bug that no one noticed before because no one ever cared to change the line style in a callout from code(?)

    Gary

  15. #15
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: On further review...

    ... it gets even worse (buggier).

    Try running the following code in a document that contains at several callouts, including one or more from the first row of callouts that are available in the popup window:

    <pre>Sub SelectCallouts()
    Dim myShape As Shape
    For Each myShape In ActiveDocument.Shapes
    If myShape.Type = msoCallout Then
    myShape.Select
    MsgBox "Callout is selected"
    Selection.Collapse
    End If
    Next myShape
    End Sub
    </pre>

    - you should see a message box for each callout in the document, and the callout will appear selected.

    The surprise is that you will get the message box for some callouts, but not for others (for example none of the ones in the first row)!

    So it appears that some styles of callouts can be controlled programatically, and others can't.... <img src=/S/confused.gif border=0 alt=confused width=15 height=20>
    (tested in Word 2000)

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •