M
mrb712
I would like to copy the autotext entries from one template to another
(and many others) using a VBA script. I found one in this group, but it
appears to need some tweaking that I'm not familiar with, and I'm
hoping to pick some of your brains for help. Below is the code as I
have it now:
Sub CopyAutoText()
Dim aEntry As AutoTextEntry
Dim OldTemplate As String
Dim TempDoc As Document
OldTemplate = "Z:\Templates\new.dot"
Set TempDoc = Documents.Add(Template:=OldTemplate, Visible:=False)
For Each aEntry In TempDoc.AttachedTemplate.AutoTextEntries
Application.OrganizerCopy
Source:=TempDoc.AttachedTemplate.FullName, _
Destination:=NormalTemplate.FullName, _
Name:=aEntry.Name, _
Object:=wdOrganizerObjectAutoText
Next aEntry
TempDoc.Close SaveChanges:=wdDoNotSaveChanges
Set TempDoc = Nothing
End Sub
The template "new.dot" is a blank template in which I store styles and
autotext to be copied into multiple content templates. I would like to
know if there is a way to make the code copy the autotext from
"new.dot" to the currently opened document. That's all. I'll save the
..dot and close it myself.
I'm using the copystylesfromtemplate code from MS Word's help file, and
I would like to use the script above to copy the AutoText entries as
well. I have literally hundreds of templates to maintain, and I would
like to automate this process as much as possible. I don't have a batch
script to perform this function, so I have to do this to each template
individually.
Thank you for any help,
mrb
(and many others) using a VBA script. I found one in this group, but it
appears to need some tweaking that I'm not familiar with, and I'm
hoping to pick some of your brains for help. Below is the code as I
have it now:
Sub CopyAutoText()
Dim aEntry As AutoTextEntry
Dim OldTemplate As String
Dim TempDoc As Document
OldTemplate = "Z:\Templates\new.dot"
Set TempDoc = Documents.Add(Template:=OldTemplate, Visible:=False)
For Each aEntry In TempDoc.AttachedTemplate.AutoTextEntries
Application.OrganizerCopy
Source:=TempDoc.AttachedTemplate.FullName, _
Destination:=NormalTemplate.FullName, _
Name:=aEntry.Name, _
Object:=wdOrganizerObjectAutoText
Next aEntry
TempDoc.Close SaveChanges:=wdDoNotSaveChanges
Set TempDoc = Nothing
End Sub
The template "new.dot" is a blank template in which I store styles and
autotext to be copied into multiple content templates. I would like to
know if there is a way to make the code copy the autotext from
"new.dot" to the currently opened document. That's all. I'll save the
..dot and close it myself.
I'm using the copystylesfromtemplate code from MS Word's help file, and
I would like to use the script above to copy the AutoText entries as
well. I have literally hundreds of templates to maintain, and I would
like to automate this process as much as possible. I don't have a batch
script to perform this function, so I have to do this to each template
individually.
Thank you for any help,
mrb