
Create an AutoTextEntry with it's value set to a document variable
Thanks for the trick Dave.
Is there a way to create the field in memory (not actually insert it in the
document) and just assign it to the AutoTextEntry. I will have variable
number AutoTextEntries created based on the document's charateristic when a
document is opened. I don't want to add bunch of fields to the document and
delete them after I create the AutoTextEntrys for them. It would be annoying
to the user. But if I don't have any other choice, I'll live with this.
Thanks, again.
-Harun
Quote:
> Hi Harun
> You have to select the field in your code and then add the AutoText Entry
> based on the selection.
> Templates[TemplateName].AutoTextEntries.Add _
> Name:="whatever", Range:=Selection.Range
> Regards
> Dave
> | Using VBA, I need to create an AutoTextEntry and set it's value to a
> | Document variable which would be dynamicly changed during the life of
the
> | document.
> |
> | I tried the following in word:
> | I inserted a field in to the document using DOCVARIABLE field code and
> | passing the document variable name as the parameter. I also selected
that
> | field in the document and created an AutoTextEntry for it. It worked
fine
> | but I need to do this in vba.
> |
> | In VBA, I tried using CreateAutoTextEntry method and created an
> | AutoTextEntry. I also tried adding a Field to the Fields collection
which
> | added the field into the document (I don't really prefer this method,
> | because I don't need the field in the document at the time of
> AutoTextEntry
> | creation. I only want the user to insert the AutoTextEntry when he/she
> needs
> | it). But I couldn't assign the field to the AutoTextEntry's value,
though
> I
> | was able to do this manually as I described above.
> | Please help.
> |
> | Thanks,
> |
> | -Harun
> |
> |