PDA

View Full Version : Solved: Make AutoText Available to All Word Files?



clhare
05-17-2005, 07:52 AM
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:


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


What am I doing wrong?

Cheryl
:dunno

MOS MASTER
05-17-2005, 10:20 AM
Hi Cheryl, :D

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:

Application.NormalTemplate.AutoTextEntries("MyAt").Insert _
Where:=Selection.Range, RichText:=True


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! :whistle:

Bilby
05-17-2005, 03:09 PM
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. ...

Bilby
05-17-2005, 03:22 PM
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.

Bilby
05-17-2005, 04:40 PM
Simpler yet,

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

MOS MASTER
05-18-2005, 09:52 AM
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, :D

Looking at your posts..aren't we telling pretty much the same story? :*)

fumei
05-20-2005, 11:51 AM
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?

MOS MASTER
05-20-2005, 12:00 PM
Well have that same problem over here..always confused! :rofl:

But like you I'm still waiting for Cheryl to clarify so we can proceed...:dunno

clhare
05-30-2005, 07:11 PM
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

MOS MASTER
05-31-2005, 12:23 PM
Hi Cheryl,

No problem..glad I could help! :yes