Consulting

Results 1 to 10 of 10

Thread: Solved: Make AutoText Available to All Word Files?

  1. #1
    VBAX Mentor clhare's Avatar
    Joined
    Mar 2005
    Posts
    470
    Location

    Solved: Make AutoText Available to All Word Files?

    I need to update alot of files and I've set up an AutoText to make it easier to do. How do I make this AutoText entry available to any Word doc or template file so I can easily add it?

    I tried putting the AutoText entry in a template in my Startup and used the following code to insert it. It works if I want to add the AutoText entry to a Word doc, but if I try to add it to a Word template, I get a Run-time error '4198' Command Failed and when I hit debug, it goes to the code in red below:

    [VBA]
    Sub AddMyAT()

    Dim strTemplate As String
    ' Determine what template document is originally attached to
    strTemplate = ActiveDocument.AttachedTemplate
    With ActiveDocument
    .UpdateStylesOnOpen = True
    .AttachedTemplate = "c:\program files\microsoft office xp\office10\startup\Cheryl's AT.dot"
    .UpdateStylesOnOpen = False
    Set rngFind = .Content
    End With

    ActiveDocument.AttachedTemplate.AutoTextEntries("MyAT").Insert Where:= _
    Selection.Range, RichText:=True
    End Sub
    [/VBA]

    What am I doing wrong?

    Cheryl

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Guru MOS MASTER's Avatar
    Joined
    Apr 2005
    Location
    Breda, The Netherlands
    Posts
    3,281
    Location
    Hi Cheryl,

    Don't know if I understand your question correct.

    You want to insert Autotext in to a document? Wel the easiest way is to put all autotextentries in Normal.dot.

    Then you can use something like:
    [VBA]
    Application.NormalTemplate.AutoTextEntries("MyAt").Insert _
    Where:=Selection.Range, RichText:=True
    [/VBA]

    That would be the answer to your question I think. (if I understand it that is)

    Your code hower is crashing on attaching another template to the activedocument.

    That's strange to me because you're talking about inserting autotext here...

    Is it true that you also want to change the attached template to the document you're opening.

    Oh the reason that you're code is giving an error is because you cannot attach a template to a template!! (Only reference to another and this not the same action of course)

    So for templates you have to leave the attaching part out of there..

    Enjoy!
    _________
    Groetjes,

    Joost Verdaasdonk
    M.O.S. Master

    Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
    (I don't answer questions asked through E-mail or PM's)

  3. #3
    VBAX Regular
    Joined
    Sep 2004
    Posts
    65
    Location
    Have you tried opening the Template, copying the AutoText over and then closing it?
    Alternatively use Organiser to copy from template to template directly. This could be automated by testing the targets file extension. If its dot then use organiser. ...

  4. #4
    VBAX Regular
    Joined
    Sep 2004
    Posts
    65
    Location
    Having a second thought.. If you tried to use your code on a template directly it would fail becouse a template cannot have an attached template.

  5. #5
    VBAX Regular
    Joined
    Sep 2004
    Posts
    65
    Location
    Simpler yet,

    [VBA] Templates("c:\program files\microsoft office xp\office10\startup\Cheryl's AT.dot") _
    .AutoTextEntries("MyAT").Insert _
    Where:=Selection.Range, _
    RichText:=True
    [/VBA]

  6. #6
    Administrator
    VP-Knowledge Base
    VBAX Guru MOS MASTER's Avatar
    Joined
    Apr 2005
    Location
    Breda, The Netherlands
    Posts
    3,281
    Location
    Quote Originally Posted by Bilby
    Having a second thought.. If you tried to use your code on a template directly it would fail becouse a template cannot have an attached template.
    Hi,

    Looking at your posts..aren't we telling pretty much the same story?
    _________
    Groetjes,

    Joost Verdaasdonk
    M.O.S. Master

    Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
    (I don't answer questions asked through E-mail or PM's)

  7. #7
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    I'm confused - true, not an uncommon state for me - but, what is the problem here again.

    Cheryl, are you trying in actually insert an AutoText entry, make one, or copy one?

  8. #8
    Administrator
    VP-Knowledge Base
    VBAX Guru MOS MASTER's Avatar
    Joined
    Apr 2005
    Location
    Breda, The Netherlands
    Posts
    3,281
    Location
    Well have that same problem over here..always confused!

    But like you I'm still waiting for Cheryl to clarify so we can proceed...
    _________
    Groetjes,

    Joost Verdaasdonk
    M.O.S. Master

    Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
    (I don't answer questions asked through E-mail or PM's)

  9. #9
    VBAX Mentor clhare's Avatar
    Joined
    Mar 2005
    Posts
    470
    Location
    Sorry for the long delay....I got pushed off that track and run over by a train on a different one!

    I was trying to add an AutoText entry to any template file at any time. I've added the AutoText entries to Normal.dot as suggested above (without the code attaching a template to a a template) and it is working.

    Thank you for your help, and again...I really apologize for dropping the ball on this question.

    Cheryl

  10. #10
    Administrator
    VP-Knowledge Base
    VBAX Guru MOS MASTER's Avatar
    Joined
    Apr 2005
    Location
    Breda, The Netherlands
    Posts
    3,281
    Location
    Hi Cheryl,

    No problem..glad I could help!
    _________
    Groetjes,

    Joost Verdaasdonk
    M.O.S. Master

    Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
    (I don't answer questions asked through E-mail or PM's)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •