c# - Word interop cross referencing an endnote -


i trying refer existing end note in word table cell in document (using netoffice):

row.cells[2].range.insertcrossreference(wdreferencetype.wdreftypeendnote, wdreferencekind.wdendnotenumberformatted, 1); 

however, appears put reference @ beginning of row, rather @ end of text @ cell[2]. in general, haven't found on web on how programmatically add cross-reference footnotes , end notes. how can reference display properly?

the problem target range specified in code snippet entire cell. need "collapse" range within cell. (think of range selection. if click @ edge of cell, entire cell selected, including structural elements. if press left-arrow, selection collapsed blinking i-beam.)

to go start of cell:

word.range rngcell = row.cells[2].range; rngcell.collapse(word.wdcollapsedirection.wdcollapsestart); rngcell.insertcrossreference(wdreferencetype.wdreftypeendnote, wdreferencekind.wdendnotenumberformatted, 1); 

if cell has content , want @ end of content, use wdcollapseend instead. tricky part puts target point @ start of next cell, has moved 1 character:

word.range rngcell = row.cells[2].range; rngcell.collapse(word.wdcollapsedirection.wdcollapseend); rng.moveend(word.wdunits.wdcharacter, -1); rngcell.insertcrossreference(wdreferencetype.wdreftypeendnote, wdreferencekind.wdendnotenumberformatted, 1); 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -