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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Renaming AutoText entries

Status
Not open for further replies.

munkt0n

Programmer
Sep 19, 2001
1
GB
I've got a document with over 100 autotext entries within.

I need to change the names of these AutoText entries

This code should do the job

Sub rename_autotext()

For Each i In Templates(1).AutoTextEntries
new_name = ""
current_name = i.Name
new_name = "AG" & current_name
i.Name = new_name
Next i

End Sub


eg an autotext entry called "100" would be renamed to "AG100"

getting rid of the "i.name = new_name" line and replacing it with "debug.print new_name" confirms this.

But....

When the code is run, the first 50 or so AutoText names remain unchanged then the rest are duplicated in various puzzling ways

eg

100 (not changed)
AG100 (changed...Hooray!)
AGAG100 (eh? if this is part of a collection why is it being processed twice?)
AGAGAG100 (3 times?????)
AGAGAGAG100 (4 times!)

I've also tried using the long-winded OrganizerRename method, which produces exactly the same results, but takes 3 times as long...

Stepping thru the code has indicated that when the name is changed, the index (of the autotext entry) is automatically set to 127

VBHelp says that the name property is read/write

Any ideas?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top