Searching for text boxes

C

Chad Williams

Is there a way to search for text boxes within a word (Microsoft Office
Professional Edition 2003 version) document? Searching for "graphics" does
not do the trick. I can't find anyone who can figure this out. Thank you!
 
D

Doug Robbins - Word MVP

What do you want to do when you find them.

Running the following macro will find them

Dim i As Long
With ActiveDocument
For i = 1 To .Shapes.Count
If .Shapes(i).Type = msoTextBox Then
.Shapes(i).Select
MsgBox "The selected shape is a text box."
End If
Next i
End With


--
Hope this helps,

Doug Robbins - Word MVP

Please reply only to the newsgroups unless you wish to obtain my services on
a paid professional basis.
 
C

Chad Williams

Doug, thank you for your response -- however, I don't understand you. When I
do a scan cleanup --sometimes using Omnipro-- I want to be able to search for
all the text boxes in the document. How do I run the macro you posted below?
Do I go to "Tools", "Macros" and then do something? If possible, please
explain. Thanks, Chad.
 
C

Chad Williams

Doug, thanks again for your reply. I read the article and I was able to
figure it out. However, I created a document with 20 boxes. The search
macro that is listed here doesn't take me from box to box. Is that the fault
of the macro? Could you try a simple test and let me know please? Thank
you. Chad.
 
D

Doug Robbins - Word MVP

I did test the macro before I sent it. Exactly what type of Text boxes are
you talking about? How were they inserted into the document?

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
C

Chad Williams

Doug, here's the problem. I have to convert huge documents from pdf into
Word. I use Omni pro and the document ends up with many many text boxes and
I want to be able to search for them going down the document from one to the
next, in the same way that you would search for any word. The macro you gave
me here did work. It would take me to a text box. But it kept going back to
the same box. I want the macro to search for the first text box and then,
when I run the macro again from that point, I want it to go to the next text
box. It wasn't doing that. I don't know if that's the fault of the macro or
of my ignorance in using it.

Thanks,
Chad.
 
D

Doug Robbins - Word MVP

The following might work for you

Dim i As Long
Dim myrange As Range
Set myrange = Selection.Range
myrange.End = ActiveDocument.Range.End
With myrange
If .ShapeRange.Count > 0 Then
For i = 1 To .ShapeRange.Count
If .ShapeRange(i).Type = msoTextBox Then
.ShapeRange(i).Select
MsgBox "The selected shape is a text box."
Exit Sub
End If
Next i
End If
End With

You will have to move the selection out of the text box before running it
again and it will only pick up one shape per shape anchor location.

--
Hope this helps,

Doug Robbins - Word MVP

Please reply only to the newsgroups unless you wish to obtain my services on
a paid professional basis.
 
C

Chad Williams

Hi Doug. Thanks again for the effort. I used the macro you put here... but
it's the same problem. It does find the first text box. Then I move the
cursor after that first text box and hit "Alt+F8" "Run" and that's where the
snag is. It doesn't take me to the next text box. It takes me to the last
text box. And actually it doesn't take me anywhere... in other words, the
cursor simply disappears. I then click on the page where I am and hit "Shift
F5" to go to the previous location -- this was my workaround to find where
the cursor was last.... and that's when it takes me to the last text box. I
wish the macro simply took me to the text boxes in the order that they are in
the document. Any further tweaking of that macro would be helpful. Thanks.
Chad.
 
G

Graham Mayor

It might be simpler with an application that formats with text boxes to scan
to plain text (which does not support then) and add your own formatting - or
to use an OCR software package that does not use text boxes such as
FineReader. Doesn't OmniPage have an option not to use text boxes?
Attempting to remove the formatting by simply removing the text boxes (which
may not be text boxes but frames) will result in a hell of a lot of work and
cannot readily be achieved with a macro.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
C

Chad Williams

Graham, thanks for your response.

Actually, I simply want to find all the text boxes and then delete them. A
lot of the times they are in footers, as well. Being able to search for text
boxes, the same way you can search for, say, any word or any style would be
so helpful. I know that you can search for graphics in a document. I wonder
why an option for searching for text boxes isn't also available? Anyhow, I
guess I'll just have to live with it as is.
 
P

Peter T. Daniels

A while ago, I exported some text from a pdf into a Word file, and a
lot of it was in text boxes (or maybe frames), and someone here
suggested Ctrl-A, Ctrl-Q. It worked.
 
G

Graham Mayor

'Text boxes' can be in line or floating and may not be text boxes but
frames or even table cells or a combination of all of them. They all require
different methods or handling. The macro suggested by Doug would deal with
normally inserted text boxes. If it doesn'y there is some other issue
involved. If you want to send me (one page of) your document to look at I
may be in a better position to advise on how to deal with them. Use the link
on the home page of my web site. Don't change the message title or the
message and attachment will be discarded.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
C

Chad Williams

Thank you Peter, but that's not what I want. I just want to be able to go
from one text box to another. "Ctrl-A, Ctrl-Q" doesn't do that. But I do
appreciate your trying to help.
 
C

Chad Williams

Thank you Graham.

Graham Mayor said:
'Text boxes' can be in line or floating and may not be text boxes but
frames or even table cells or a combination of all of them. They all require
different methods or handling. The macro suggested by Doug would deal with
normally inserted text boxes. If it doesn'y there is some other issue
involved. If you want to send me (one page of) your document to look at I
may be in a better position to advise on how to deal with them. Use the link
on the home page of my web site. Don't change the message title or the
message and attachment will be discarded.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>






.
 
P

Peter T. Daniels

Note that in none of your responses have you said what you actually
want to _do_ with each of the text boxes! If you reveal that
information, someone like Graham might be able to create a macro that
does it. (Once you seemed to indicate that you want to convert boxed
text to plain text, which is what my procedure will do.)
 
C

Chad Williams

I honestly thank you for your help, Peter. Maybe you didn't read my very
first post where I simply was asking for help in how to simply search for
text boxes within a document, in the same way you would search for a word. I
never really specified the reason. Maybe you came in later in the thread.
But I do appreciate your help and anyone's help here. As you know, there's a
lot to know when it comes to heavy-duty Word document work. Chad.
 
S

Suzanne S. Barnhill

Peter was pointing out that you didn't say why you wanted to search for text
boxes. A little more detail would have helped us fine-tune our advice
because some of the questions that come up are, for example, "Are these
really text boxes, or might they be frames instead?" and "Do you want to
find them in order to delete them entirely, or do you want to preserve their
content but remove it from the text boxes and then delete the text boxes?"
and "Do you want to find the text boxes in order to apply some sort of
consistent formatting?" And so on.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org
 
C

Chad Williams

Thank you Suzanne and thank you Peter. Sorry, I thought I was clear and now
I see the problem. Well, I simply would like a macro (if you can do it) to
search for the next text box in the document and have the cursor bring me to
that text box and then stop. Then, at that point, I would determine what I
want to do with that text box. Then, I want to run the macro again from
where my cursor is (at that point I would place it after the first text box)
and then have the macro take my cursor to the next text box and stop. And so
forth. (If you can do another macro for frames, that would be an added
bonus.) But it's more the text box search that I would love to have. And
I'm praying that I have been more clear here than previously. Thank you.
Chad.
 
G

Graham Mayor

As I offered a few days ago, if you send me a sample of the document, I will
see what needs to be done to locate the boxes it contains.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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