How can I find simplefields in a footer?

Posted by: david.sheppard on 20 May 2019, 11:06 pm EST

    • Post Options:
    • Link

    Posted 20 May 2019, 11:06 pm EST

    I want to find the simplefields that are in the footer for a document.body.section. Can I perform a getrange on the footer? How can I find the simplefields in the header and footer?

    When I want to find the simplefields in a section of a document the simplefields appear as a simplefields collection when I perform a getrange on the section. For example:

    DocSecRange1 = Doc1.Body.Sections(0).GetRange()

    For IndexField = 0 to DocSecRange1.SimpleFields.Count -1

    Field1 = DocSecRange1.SimpleFields(IndexField)

  • Posted 23 May 2019, 3:48 am EST

    Hello,

    To perform GetRange for a section footer, you should use footers.Body.Paragraphs collection and then invoke the GetRange method.

    So, to be able to find the SimpleFields in section footer, you should follow this hierarchy: GcWordDocument → Body → Section → Footers → Body → Paragraphs → GetRange method → SimpleFields, as follows:

            For Each Section In Doc1.Body.Sections
                Dim Footers = Section.Footers(HeaderFooterType.Primary)
                For Each Para In Footers.Body.Paragraphs
                    Dim FooterParaRange = Para.GetRange()
                    For Each Field In FooterParaRange.SimpleFields
                        Dim FieldCode = Field.Code.Trim
                        Debug.WriteLine($"Old Code: {FieldCode}")
                    Next
                Next
            Next
    
    

    Also, attached is a sample application for your reference.

    Regards,

    Esha

    SimpleFields_Footer.zip

Need extra support?

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

Learn More

Forum Channels