c# - Microsoft Office Interop Word read header and footnote -


i want use microsoft office interop word assemblies read header , footers of word documents.

i have 2 problems :

first how access footnotes , headers? second how convert them string (i got "system.__comobject" when call tostring())

you should have document object doc composed of many sections, , footers/headers part of single sections. each section can have multiple headers/footers (they can instance different first page). access text of header/footer have range contained in header/footer, , access text property.

if app word applicationclass, code should give 2 collections headers , footers of active document:

        list<string> headers = new list<string>();         list<string> footers = new list<string>();         foreach (section asection in app.activedocument.sections)         {             foreach (headerfooter aheader in asection.headers)                 headers.add(aheader.range.text);             foreach (headerfooter afooter in asection.footers)                 footers.add(afooter.range.text);         }  

if interested in footnotes instead of footers (it's not clear question, since wrote footnotes in places, , footers in others), things simpler, since can ask document collection of footnotes. access text inside note can same seen headers/footers: access range , text property:

        list<string> footnotes = new list<string>();         foreach (footnote anote in app.activedocument.footnotes)             footnotes.add(anote.range.text); 

Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -