none
How to get fields from footer RRS feed

  • Question

  • Hi,

    I want to get fields (Microsoft.office.interop.word.fields) which are inserted in the footer of document.

    but word.Document.content.fields will return fields from the main body only. and field.count also will return count from the main body. how can I get the fields present in the footnote.

    Thanks.

    Wednesday, July 1, 2015 7:53 AM

Answers

  • well, assuming you have the document you are working with in a variable called doc:

    foreach (range rng in doc.StoryRanges) {
    	//do something with the rang here
    
    }

    Really, you should be able to interpret object oriented statements between languages it's not difficult.

    If you are looking to edit a specific story range from vsto, you will probably need the fully qualified reference to the storyType unless you have included the relevant library

    e.g. Word.WdStoryType.wdPrimaryFooterStory

    • Proposed as answer by L.HlModerator Thursday, July 2, 2015 3:17 AM
    • Marked as answer by L.HlModerator Thursday, July 9, 2015 2:41 AM
    Wednesday, July 1, 2015 10:52 AM

All replies

  • You will be able to find the footer in one of the storyranges, depening on how you have your header/footer options set (different first page, different odd and even pages can make this more confusing).

    This code will loop all story ranges and you will find your field in one of them:

    Dim rng As Range
    
    For Each rng In ActiveDocument.StoryRanges
        If rng.Fields.Count > 0 Then
            Debug.Print rng.Fields.Count
        End If
    Next

    Usually, though what you are looking for will be in the Primary Footer Range:

    activedocument.StoryRanges(wdPrimaryFooterStory)
    

    Wednesday, July 1, 2015 8:36 AM
  • How to do this in c# coding.?
    Wednesday, July 1, 2015 9:19 AM
  • well, assuming you have the document you are working with in a variable called doc:

    foreach (range rng in doc.StoryRanges) {
    	//do something with the rang here
    
    }

    Really, you should be able to interpret object oriented statements between languages it's not difficult.

    If you are looking to edit a specific story range from vsto, you will probably need the fully qualified reference to the storyType unless you have included the relevant library

    e.g. Word.WdStoryType.wdPrimaryFooterStory

    • Proposed as answer by L.HlModerator Thursday, July 2, 2015 3:17 AM
    • Marked as answer by L.HlModerator Thursday, July 9, 2015 2:41 AM
    Wednesday, July 1, 2015 10:52 AM