Inserting Autotext using VBA - loses formatting and styles 
Author Message
 Inserting Autotext using VBA - loses formatting and styles

Hi there,
I'm using Word 2000 creating a Word template to be used for training manual
development.  I make use of several autotext entries with proper formatting
and styles.  For instance, I have the sanctioned format for an If-Then-Table
(used for step by step training manuals) saved as an autotext entry.  Then I
have a custom menu where the user can easily add an If-Then-Table to the
active document.  My question is this... I use the following code to move to
the end of the document (in this case) and insert an autotext entry:

 Selection.EndKey Unit:=wdStory
    Selection.InsertBreak Type:=wdPageBreak
ActiveDocument.AttachedTemplate.AutoTextEntries("1  If-Then Table").Insert _
         Where:=Selection.Range

My problem is that the autotext entry loses all formatting, like style when
its inserted (works perfectly if I manully move to the end of the document
and isnert the same autotext entry).

Any ideas?  Thank in advance.



Tue, 13 Jan 2004 23:15:06 GMT  
 Inserting Autotext using VBA - loses formatting and styles
Hi BJP

There is in additional argument
Insert(Where, RichText)

if richtext is true you get what you want!

Michael



Quote:
> Hi there,
> I'm using Word 2000 creating a Word template to be used for training
manual
> development.  I make use of several autotext entries with proper
formatting
> and styles.  For instance, I have the sanctioned format for an
If-Then-Table
> (used for step by step training manuals) saved as an autotext entry.  Then
I
> have a custom menu where the user can easily add an If-Then-Table to the
> active document.  My question is this... I use the following code to move
to
> the end of the document (in this case) and insert an autotext entry:

>  Selection.EndKey Unit:=wdStory
>     Selection.InsertBreak Type:=wdPageBreak
> ActiveDocument.AttachedTemplate.AutoTextEntries("1  If-Then Table").Insert
_
>          Where:=Selection.Range

> My problem is that the autotext entry loses all formatting, like style
when
> its inserted (works perfectly if I manully move to the end of the document
> and isnert the same autotext entry).

> Any ideas?  Thank in advance.



Wed, 14 Jan 2004 00:00:14 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Macro that inserts Autotext loses styles of Autotext entry

2. Problem with format on insert autotext, and in inserting elements with form fields

3. Formatting a style using VBA

4. Inserting AutoText in Header and retaining formatting

5. Insert Autotext - returned range depends on formatting?

6. Insert autotext with VBa

7. Insert autotext with vba

8. Autotext Insert in Cell Using Range

9. Styles defined in VBA lose their shortcuts (aliases) - but not always

10. Styles defined in VBA lose their shortcuts (aliases) - but not always - addendum

11. Help needed: Generating table from styles/inserting objects with custom formatting

12. Using VBA to enter text that Autotext will recongnise

 

 
Powered by phpBB® Forum Software