
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/