PDA

View Full Version : Autotext - mass changes using visual basic?


Greg G
01-04-2005, 12:30 PM
I have a document template set up that has over 100+ customized autotext entries.

Can someone post code to help me accomplish the following?

I want to be able to do a search and replace on all autotext entries. Here is an example:

Autotext1: "Welcome" ~ text = "Thank you for your business"

Autotext2: "Bye" ~ text = "Should you have any questions"

Search for "you" and replace it with "you and your associates"

Thank you in advance for your help.

Greg

Greg G
01-06-2005, 11:14 AM
I realize there isn't a truly clean way to do this... so this is what I've come up with.

Step 1: VB-Load the autotext into a word doc and save it to temp directory.
Step 2: Open the documents and do my manual changes
Step 3: VB-Delete old autotext from Normal.dot and reload individual autotext into Normal.dot

Questions/help: In step 1, how can I surpress the following prompt: "Doc contains links, want to refresh...?" I want that to default to NO and not prompt me.

Questions/help: In step 3, how can I surpress the prompt "do you want to save changes..." I want the default to be YES and not prompt me.

Questions/help: Finally, I can't get the coding correct as a last step to move all my autotext entries out of normal.dot into the correct PS.doc file.

Thank you so much in advance! Greg

Sub PS_changes()

'extract all autotext entries and save them to C:\Temp for editing

Selection.WholeStory
ActiveDocument.AttachedTemplate.AutoTextEntries("zz0100").Insert Where:= _
Selection.Range, RichText:=True
ActiveDocument.SaveAs FileName:="c:\temp\zz0100.doc"

End Sub

Sub PS_changes_2()

'delete all autotext entries in normal.dot
NormalTemplate.AutoTextEntries("zz0100").Delete

'open and save new autotext entries in normal.dot
Documents.Open FileName:="c:\temp\zz0100.doc"
Selection.WholeStory
NormalTemplate.AutoTextEntries.Add _
Range:=Selection.Range, Name:="zz0100"
ActiveDocument.Close

End Sub