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.
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
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.