replace simplefield with text

Posted by: david.sheppard on 20 May 2019, 1:19 am EST

  • Posted 20 May 2019, 1:19 am EST

    I 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?
  • Replied 20 May 2019, 6:24 pm EST


    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 EST

    I 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 EST

    Great 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.

    Best wishes,
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels