First, let me thank you for the solution. It does seem like the only way is
to loop through all of the active templates (which is lame, the other coding
you mentioned should work).
Second, The solution you gave me inserts the autotext entry but it is
unformatted. The heading which was Bold and Centered in the autotext entry
is now left aligned with no bold (basically everything is Normal style).
If I manually insert the same autotext entry using
Tools/Autocorrect/Autotext, it will insert the entry with all of the correct
formatting so I know the autotext entry is correct. When I record the macro
for inserting the Autotext entry it is inserting it using the same coding you
gave me for the solution.
Recorded Macro:
ActiveDocument.AttachedTemplate.AutoTextEntries("Form").Insert
Where:=Selection.Range
Your solution:
temp.AutoTextEntries("Form").Insert Where:=Selection.Range
I can't figure that one out. There is an easy solution for me, I can just
automatically move the cursor to the top 3 lines and center/bold the heading
with an additional routine after the the autotext gets inserted, but I would
like to see if there is a way to insert the autotext entry with the
formatting in tact if possible.
> Hi Frank,
>
[quoted text clipped - 72 lines]
> > ActiveDocument.AttachedTemplate.AutoTextEntries("Form").Insert Where _
> > :=Selection.Range
frank - 15 Feb 2007 03:36 GMT
Actually, I figured it out. I used your solution to cycle through the
attached templates and I found on another website that you can use ",
RichText:=True" directly after the insert command to retain the formatting.
temp.AutoTextEntries("Form").Insert Where:=Selection.Range, RichText:=True
Thanks so much for everything!
> First, let me thank you for the solution. It does seem like the only way is
> to loop through all of the active templates (which is lame, the other coding
[quoted text clipped - 99 lines]
> > > ActiveDocument.AttachedTemplate.AutoTextEntries("Form").Insert Where _
> > > :=Selection.Range
Jay Freedman - 15 Feb 2007 03:41 GMT
The .Insert method has a second (optional) parameter, RichText -- this
is described in the VBA help topic about the method. If you omit it,
the parameter takes the default value of False, so the entry is
inserted as unformatted. If you include it and set it to True, the
entry is inserted as formatted. The statement you want, then, is
temp.AutoTextEntries("Form").Insert Where:=Selection.Range, _
RichText:=True
Just for yucks, you should read my diatribe about some of the many
things that are unexpected or just broken in the macro recorder:
http://www.word.mvps.org/FAQs/MacrosVBA/ModifyRecordedMacro.htm
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
>First, let me thank you for the solution. It does seem like the only way is
>to loop through all of the active templates (which is lame, the other coding
[quoted text clipped - 99 lines]
>> > ActiveDocument.AttachedTemplate.AutoTextEntries("Form").Insert Where _
>> > :=Selection.Range