Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2005

Tip: Looking for answers? Try searching our database.

Deleting a Text Box programmatically

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Roderick O'Regan - 03 Mar 2005 10:51 GMT
I have created a Text Box with some text in it and then stored itas an
AutoText item in the template for the active document. I called this
autotext "~questions~". I know how to programmatically insert the
autotext in question onto the page.

However, if the user changes their mind and doesn't want the text box
is there a way of giving it a name, perhaps, and saying to VBA "...go
and find this text box named XYZ and delete it"?

Regards

Roderick O'Regan
Jezebel - 03 Mar 2005 11:26 GMT
You can give the textbox a name before you define it as an autotext entry.
It will retain that name when inserted, and you can then refer to it by
name.

To set the name, if the textbox is the only shape in the document, use --

ActiveDocument.Shapes(1).Name = "XYZ"

Then you can use

ActiveDocument.Shapes("XYZ").Delete

There's one gotcha: Word doesn't care if there are several shapes with the
same name -- as would happen if you inserted your named autotext textbox
more than once.

>I have created a Text Box with some text in it and then stored itas an
> AutoText item in the template for the active document. I called this
[quoted text clipped - 8 lines]
>
> Roderick O'Regan
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.