Problem with format on insert autotext, and in inserting elements with form fields 
Author Message
 Problem with format on insert autotext, and in inserting elements with form fields

Hi,

I'm trying to create a document that is to be used to record meeting minutes
and decisions according to a fairly tight format.

I have created and stored as AutoText two different multiline text groups
(that each contain form fields) that correspond to the two types of items
that come up routinely for decisions.  The idea is that the recorder can
simply insert an item (as AutoText) as the need arises and then use (mostly)
list selection to complete the information for that meeting item. Each
AutoText element has some style-based formatting in it for auto-numbering of
the items in the minutes and for font-color visibility.

I'm having two problems:

1.  Inserting the AutoText elements using the "Insert/AutoText ..."
drop-down menu, works, as does a click on the AutoText button on the tool
bar (when I include it), but when I record each of the two AutoText
insertions as a macro (for later assignment to a custom button to allow
simple a "click for element insertion") I find that all formatting is
stripped from the AutoText element that has been inserted.  I don't know
why, since the basic AutoText insert is OK, and all I did was record the
macro.  Any suggestions as to why this happens and how I can ensure that the
formatting is retained would be welcome.

2.  I need to allow users to add the two different AutoText elements as the
meeting proceeds, but want them to use the fields within each element after
it is inserted.  To allow the user to complete the form fields in each
AutoText element I need to protect the form, but then I find that the user
cannot insert the AutoText elements, as needed, for each new meeting item.
I'm thinking that I may be taking an entirely incorrect approach to what I'm
trying to do here.  Any ideas?

Many thanks for any help on this.

Allen Brown



Sat, 10 Jul 2004 05:29:44 GMT  
 Problem with format on insert autotext, and in inserting elements with form fields
Hi Allen,

Quote:
> 1.  Inserting the AutoText elements using the "Insert/AutoText ..."
> drop-down menu, works, as does a click on the AutoText button on the tool
> bar (when I include it), but when I record each of the two AutoText
> insertions as a macro (for later assignment to a custom button to allow
> simple a "click for element insertion") I find that all formatting is
> stripped from the AutoText element that has been inserted.  I don't know
> why, since the basic AutoText insert is OK, and all I did was record the
> macro.  Any suggestions as to why this happens and how I can ensure that
the
> formatting is retained would be welcome.

Probably, you need to set the RichText property in your code. I think this
is not recorded when you record the actions.

If you autotextentry is stored in the normal template, use:

    normaltemplate.AutoTextEntries("asx").Insert _
                           where:=selection.Range,richtext:=true

if it's in another template use:

    Templates("C:\path\filename.dot").AutoTextEntries("asx").Insert _
                    where:=selection.Range,richtext:=true

Quote:
> 2.  I need to allow users to add the two different AutoText elements as
the
> meeting proceeds, but want them to use the fields within each element
after
> it is inserted.  To allow the user to complete the form fields in each
> AutoText element I need to protect the form, but then I find that the user
> cannot insert the AutoText elements, as needed, for each new meeting item.
> I'm thinking that I may be taking an entirely incorrect approach to what
I'm
> trying to do here.  Any ideas?

You can follow the approach if none of your code depends on the name of the
formfields. The name of a formfield is a bookmark and can only be used once
in a document. If you copy the field, the name for the first field is gone,
and the second one will own the name. The name of the first field is empty.
This doesn't have to be a problem, if you don't use the fields in your code
or don't use REF fields inside your document to repeat the text at another
position.

If you want to do this with a macro, you need to unprotect the document
first, add the formfield and then reprotect the document:

    ActiveDocument.Unprotect
    Templates("C:\path\filename.dot").AutoTextEntries("asx").Insert _
                    Where:=Selection.Range,RichText:=True
    ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _
                   noreset:=True

Hope this helps,
regards,
Astrid

So that all can benefit from the discussion, please post all follow-ups to
the newsgroup.
Visit the MVP Word FAQ site at http://www.mvps.org/word/



Sat, 10 Jul 2004 06:43:04 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Inserting AutoText in Header and retaining formatting

2. Inserting Autotext using VBA - loses formatting and styles

3. Insert Autotext - returned range depends on formatting?

4. Macro that inserts Autotext loses styles of Autotext entry

5. Insert multiple child elements to a parent element

6. Problem Inserting batch insert statement

7. Inserting AutoText from a Global Template

8. Insert autotext with VBa

9. Insert Autotext Entries in a Document

10. Autotext Insert in Cell Using Range

11. Word XP- Insert Autotext- Tables

12. Insert AutoText in Footer via Macro

 

 
Powered by phpBB® Forum Software