Word 2003 select text box

K

Kerry Purdy

Hi,

I need to create a routine which will find all text boxes in the open
document and delete them. Is anyone able to advise me please.

Many thanks for your time.

Kerry
 
G

Greg Maxey

The correct answer is subject to how you define a text box. This is my
guess:

Sub ScratchMacro()
Dim oShape As SHape
For Each oShape In ActiveDocument.Shapes
If oShape.Type = msoTextBox Then oShape.Delete
Next
End Sub
 
D

David Horowitz

Right, because if your "textboxes" are FormFields, there will be a different
loop.
 
K

Kerry Purdy

Hi Guys,

Thanks for the reply.

I have tried this macro but i am getting a permission denied error.

any ideas please?

Thanks. very much
 
D

Doug Robbins - Word MVP on news.microsoft.com

What sort of Text Boxes are you dealing with? Are they actually Text Input
FormFields as used in a Protected 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
 
K

Kerry Purdy

Hi Doug,

These are type of text boxes created from the drawing toolbar. There is no
protection on the document that i can see through Tools, Protect document, it
is not even read only. I am puzzled. it is showing error code 70 if that
helps.

Many thanks for your help.

Kerry
 
D

Doug Robbins - Word MVP on news.microsoft.com

If you want to send me the document, I will take a look at it.

Just testing now, I find that Greg's code for some reason would only delete
one textbox at at time. The following code worked better for me:

Dim oShape As Shape
Dim i As Long
With ActiveDocument
For i = .Shapes.Count To 1 Step -1
If .Shapes(i).Type = msoTextBox Then
.Shapes(i).Delete
End If
Next
End With


--
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
 
K

Kerry Purdy

Hi Doug,

i tried this new code but i am still having the same permission error. I
would be very grateful if you would have a quick look at the document please.
How can i send it to you?

Many thanks

Kerry
 
D

Doug Robbins - Word MVP on news.microsoft.com

Send it to me at (e-mail address removed)

--
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
 

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