Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word w/ Delphi:autotext

Status
Not open for further replies.

cwdrama

Programmer
Mar 20, 2022
2
GR
Hello
i have some autotext that have form fields.
e.g. i have a autotext named test with 2 form fields test_field1 and test_field2 with regular text type
in my document i insert many times the autotext block and fill the fields with the code:
myTemplate.AutoTextEntries.Item('test ').Insert(msword1.Selection.Range,false);
doc.FormFields.Item('test_field1 ').result :='some text'
doc.FormFields.Item('test_field12').result :='some text'

the problem is that when i insert the autotext more than 1 time in the document it insert it but it changes the formfield values of the first inserted autotext block always and the other are empty

Please for your help



 
Formfield names must be unique. Your insertion of the second set of formfields is thus invalid in that regard. Hence, only the original set of formfields get updated.

Cheers
Paul Edstein
[Fmr MS MVP - Word]
 
thank you for your quick answering

the problem is that when i use word.basic instead of word.application everything are correct the autotext
is inserted multiple times on the document and the form fields are updated correctly on all form fields (not only on the first autotext block)
i have seen that after inserting the autotext for the first time and doubleclicked on the form_fields i see the form_field name that i have given.
when i insert again the same autotext in the first autotext formfields the names are empty and are set on the second autotext form fields so with this all blocks are updated with the text not only the first

i wanted to move from word.basic to word.application and cant made it work
i have attached the code i uses with word.basic

Please for your help
Stavros-Greece

 
 https://files.engineering.com/getfile.aspx?folder=cc03d55f-eefd-40a2-98f6-3b58e29e6367&file=autotext_example.txt
i have attached the code i uses with word.basic
It's all Greek to me...

It would be more helpful if you supplied an actual document demonstrating what you're starting with and what you're trying to achieve.

Cheers
Paul Edstein
[Fmr MS MVP - Word]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top