Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / December 2004

Tip: Looking for answers? Try searching our database.

AutoText entry not in Normal.dot

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Luc Benninger - 20 Dec 2004 15:41 GMT
I have a global template (myDot.dot) with following VBA code in it to
create a new AutoText entry. This new entry should not be saved in the
Normal.dot but in the myDot.dot:

CustomizationContext = ThisDocument
Selection.CreateAutoTextEntry "AT_Label", "AT_Category"

But it seems that the CustomizationContext instruction has no influence!
The entry is still saved in Normal.dot.

Any hints?
Thanks a lot, Luc
Jay Freedman - 20 Dec 2004 16:33 GMT
> I have a global template (myDot.dot) with following VBA code in it to
> create a new AutoText entry. This new entry should not be saved in the
[quoted text clipped - 8 lines]
> Any hints?
> Thanks a lot, Luc

Hi Luc,

"ThisDocument" is the wrong place to point to. Instead, use
  CustomizationContext = ActiveDocument.AttachedTemplate

See http://word.mvps.org/faqs/macrosvba/AddMenu.htm for an example.

Signature

Regards,
Jay Freedman
Microsoft Word MVP          FAQ: http://word.mvps.org

Charles Kenyon - 20 Dec 2004 22:14 GMT
Hi Luc and Jay,

Jay, your code works when it is in the attached template and that is where
you
want to store the AutoText entry.

The following (a combination of the two) works for storing in a global
template instead:

Sub ATTry()
   CustomizationContext = ThisDocument.AttachedTemplate
   Selection.CreateAutoTextEntry "AT_Label", "AT_Category"
End Sub

ThisDocument, by itself, doesn't work because it doesn't describe a template
(which is the only object that can hold AutoText), I think.
IMHO ActiveDocument.AttachedTemplate should never describe a global
template, other than normal.dot.

Note, I don't know how long the CustomizationContext sticks. I expect at
least as long as the procedure is running but suspect that it may be as long
as the global is loaded after the procedure is run. You should test this and
make sure because otherwise you are likely to end up with stray
customizations in your global.

Also, you probably want to save your global at the end of the procedure.

ThisDocument.Save
Signature


Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://www.mvps.org/word which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.

>> I have a global template (myDot.dot) with following VBA code in it to
>> create a new AutoText entry. This new entry should not be saved in the
[quoted text clipped - 15 lines]
>
> See http://word.mvps.org/faqs/macrosvba/AddMenu.htm for an example.
Luc Benninger - 21 Dec 2004 08:25 GMT
Thank you very much for your replies. Unfortunately none of your
suggestions seem to work for me. The new AT-entry is still saved in
Normal.dot. Does it really work that way at your end? I'm using Word XP.
Thanks again
Luc

> Hi Luc and Jay,
>
[quoted text clipped - 24 lines]
>
> ThisDocument.Save
Charles Kenyon - 21 Dec 2004 14:02 GMT
Sorry, I should have tested before posting. It still goes into normal.dot
even if the attached template is not normal.dot. This tells me that the
customization context is irrelevant for purposes of storing AT entries. The
codeI wrote puts the customization context in the global template, but
doesn't change where AT entries are stored.

The AutoTextEntries.Add method lets you specify the template (actually seems
to require it) but doesn't let you specify the style. It uses the style of
the selection for the category.

You may have to actually have and use styles and the AutoTextEntries.Add
method to do what you want. Jay has a template "AutoTextLoader.dot" with
code for loading ATEntries into a template from a table. You may want to
look at it and see if it will help you do what you need. You can get it from
my site at http://addbalance.com/word/download.htm#Templates.
Signature


Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://www.mvps.org/word which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.

> Thank you very much for your replies. Unfortunately none of your
> suggestions seem to work for me. The new AT-entry is still saved in
[quoted text clipped - 31 lines]
>>
>> ThisDocument.Save
Luc Benninger - 21 Dec 2004 14:37 GMT
Thanks Charles, your explanations are very helpful!

> Sorry, I should have tested before posting. It still goes into normal.dot
> even if the attached template is not normal.dot. This tells me that the
[quoted text clipped - 11 lines]
> look at it and see if it will help you do what you need. You can get it from
> my site at http://addbalance.com/word/download.htm#Templates.

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.