Save to other global template

T

TimDouglas

Hi,
I am creating a template that uses autotext entries taken from text boxes
and then updated throughout the document.

Dim AutoText As String
AutoText = TextBox_AutoText.text
NormalTemplate.AutoTextEntries("TextEntry").Value = AutoText

All the instances of TextEntry are then updated.

However, when i create a new document based on the template, word tries to
insert the auto text entries saved from that template, rather than
normal.dot, which is obviously where these auto text entries are being
stored. Is there any way to store the autotext entries into the other
template, rather than normal.dot?

Thanks for your help,

Tim
 
J

Jonathan West

TimDouglas said:
Hi,
I am creating a template that uses autotext entries taken from text boxes
and then updated throughout the document.

Dim AutoText As String
AutoText = TextBox_AutoText.text
NormalTemplate.AutoTextEntries("TextEntry").Value = AutoText

All the instances of TextEntry are then updated.

However, when i create a new document based on the template, word tries to
insert the auto text entries saved from that template, rather than
normal.dot, which is obviously where these auto text entries are being
stored. Is there any way to store the autotext entries into the other
template, rather than normal.dot?


They can be stored in any template you want - all you need do is accurately
describe the template. For instance, if you want to store entries in the
template on which the current document is based, you would change this line

NormalTemplate.AutoTextEntries("TextEntry").Value = AutoText

to this

ActiveDocument.AttachedTemplate.AutoTextEntries("TextEntry").Value =
AutoText

You might need to check whether the entry already exists. if it doesn't, you
will get an error, and need instead to use the Add method for the
AutotextEntries collection.


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
T

TimDouglas

Thanks, that works fine

Jonathan West said:
They can be stored in any template you want - all you need do is accurately
describe the template. For instance, if you want to store entries in the
template on which the current document is based, you would change this line

NormalTemplate.AutoTextEntries("TextEntry").Value = AutoText

to this

ActiveDocument.AttachedTemplate.AutoTextEntries("TextEntry").Value =
AutoText

You might need to check whether the entry already exists. if it doesn't, you
will get an error, and need instead to use the Add method for the
AutotextEntries collection.


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top