Posted 20 May 2019, 1:19 am ESTI want to search through the document to find simplefields and replace the simplefield with text that my program generates. I can find the simplefields by looping through the document.body.sections. I can remove the simple fields by using the simplefield.delete method. How can I insert text where the simplefield was located?
replace simplefield with text
Posted by: david.sheppard on 20 May 2019, 1:19 am EST
Replied 20 May 2019, 6:24 pm ESTHi,
I am discussing your requirement with the concerned team [ID: 1234]. I'll get back to you once we receive some information from them.
Marked as Answer
Replied 20 May 2019, 10:54 pm ESTI was able to find and replace the simplefields using the following code.
For Each DocSec1 In Doc1.Body.Sections
DocSecRange1 = DocSec1.GetRange()
For IndexField = 0 to DocSecRange1.SimpleFields.Count -1
Field1 = DocSecRange1.SimpleFields(IndexField)
FieldCode = Field1.Code.Trim
DocSecRange1.Document.Body.GetPersistentRange(Field1.Start, Field1.End).Runs.Insert("AAA", InsertLocation.Before)
Replied 21 May 2019, 9:15 pm ESTGreat that you could find a solution for your requirement.
Also, thank you for sharing the solution, it would help other members as well over the community.