Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to delete textbox via VBA (Word97)

Status
Not open for further replies.

jacron

Programmer
Feb 7, 2002
2
US
I have a Word 97 template that includes a textbox in a header... I need to delete the textbox from the header based on a user selection. I'm able to view the header but have not been able to select the textbox and delete it via VBA code.

Any suggestions?
 
If you have more than one, you need to be able to identify it.

once you identify it, you can delete it.

there are 2 types of text boxes
1) those you create from the INSERT>TEXTBOX menu item
2) those you create from the VIEW>TOOLBOX>CONTROLS menu.

The INSERT type are in the SHAPES collection, but are unnamed. However, you can set their AlternateText property to uniquely identify them.
Sub DeleteTextBox (sID as string)
dim shp as shape
for each shp in shapes
if shp.alternateText = sID then
shp.delete
exit for
end if
next
exit sub

The CONTROLS menu will create a text box in the INLINESHAPES collection. This can be given a name.
Sub DeleteTextBox (sID as string)
dim inshp as inlineshape
for each shp in inlineshapes
if inshp.OLEFormat.Object.Name = sID then
inshp.delete
exit for
end if
next
exit sub

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top