Results 1 to 11 of 11
  1. #1
    2 Star Lounger
    Join Date
    Jul 2001
    Location
    Wisconsin, USA
    Posts
    193
    Thanks
    0
    Thanked 1 Time in 1 Post

    Macro to search for text box (Word 2000)

    I've got about 500 documents, all including a text box along the left side of the page. I've figured out a macro to select the text box, reposition it and add another one above it; however, on some documents the macro won't run because of the text box number. In looking at my code, depending on which document I recorded the macro on, it says "Text Box 2" or 3 or 20, etc. I've tried deleting the number and just having it search for "Text Box" but that doesn't work either. Is there some other code I can start with that will select that text box, no matter what the number of it is?

    Thanks,

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 18 Times in 18 Posts

    Re: Macro to search for text box (Word 2000)

    Is this text box the only one in the document when you start the macro? If so, you can use code like this:

    Dim sh As Shape
    For Each sh In ActiveDocument.Shapes
    If sh.Type = msoTextBox Then
    sh.Top = 144 ' points
    ...
    Exit For
    End If
    Next sh

    If the document may already contain more than one text box, you will need to have a way to identify the one you want to move.

  3. #3
    2 Star Lounger
    Join Date
    Jul 2001
    Location
    Wisconsin, USA
    Posts
    193
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Macro to search for text box (Word 2000)

    Hans,

    Are the 3 dots where the rest of my macro would go?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 18 Times in 18 Posts

    Re: Macro to search for text box (Word 2000)

    Yes, any other code to manipulate the text box should go there.

  5. #5
    2 Star Lounger
    Join Date
    Jul 2001
    Location
    Wisconsin, USA
    Posts
    193
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Macro to search for text box (Word 2000)

    Hans,

    I put code for that particular text box in where it should have gone but when running it - it didn't do anything with that text box then errored on my next piece of code. It's entirely possible I missed something or put something in the wrong place. If I post the document could you take a look at my original code?

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 18 Times in 18 Posts

    Re: Macro to search for text box (Word 2000)

    Posting your document is a good idea. It should be less than 100 KB (zip it if it's too large). Remove sensitive information or replace it with dummy text.

  7. #7
    2 Star Lounger
    Join Date
    Jul 2001
    Location
    Wisconsin, USA
    Posts
    193
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Macro to search for text box (Word 2000)

    Heres the file. The first page was one doc and the second page was another doc but I combined for the post. The second one as a standalone document works with my original macro but the first one does not. There will never be 2 files together to have to search for the second text box.

    Thanks much!
    Attached Files Attached Files

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 18 Times in 18 Posts

    Re: Macro to search for text box (Word 2000)

    Does the macro in the attached document work for you?
    Attached Files Attached Files

  9. #9
    2 Star Lounger
    Join Date
    Jul 2001
    Location
    Wisconsin, USA
    Posts
    193
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Macro to search for text box (Word 2000)

    Hans, where in the top part would I say to resize the large text box to 7" high rather than 8.04?

  10. #10
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 18 Times in 18 Posts

    Re: Macro to search for text box (Word 2000)

    Add the line

    .Height = InchesToPoints(7)

    below the lines that set the Top and Left position.

  11. #11
    2 Star Lounger
    Join Date
    Jul 2001
    Location
    Wisconsin, USA
    Posts
    193
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Macro to search for text box (Word 2000)

    Hans,

    I cannot thank you enough for your help. It is MUCH appreciated.
    <img src=/S/thankyou.gif border=0 alt=thankyou width=40 height=15>

Posting Permissions

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