Stuart Troy said:
Thanks Jonathon,
I moved the custom template to Word's startup folder;
C:\Documents and Settings\UsernameApplication Data\Microsoft\Word\STARTUP
But when I run this code, it produces an error;
VBA Code;
Documents.Add DocumentType:=wdNewBlankDocument
ActiveDocument.AttachedTemplate.AutoTextEntries("AutoText_Name"). Insert
Where:=Selection.Range, RichText:=False
Resulting Error;
"The requested member of the collection does not exist"
As an alternative to Jonathan's suggestion, you can also do it without even
referencing any template. As long as it is indeed in the Startup folder and
that the AutoText names from that template are unique, you can use:
Dim rngAutoText As Range
Const strAutoTextName As String = "AutoText_Entry_Name"
Set rngAutoText = Selection.Range
With rngAutoText
'In case selection is not an insertion point...
.Collapse wdCollapseStart
.InsertAfter strAutoTextName
.InsertAutoText
End With
If you cannot guarantee unique names, then it is better to use Jonathan's
code. If different templates have Autotext entries with the same name, you
will pull the right one.