c# - how to insert formula in word using vsto? -


i want use formula { = {page} + 1 } in word document, tried below sample didn't worked

document.fields.add(sel.selection.range, word.wdfieldtype.wdfieldexpression, @"{page}+1", true); 

this should help

_wordapplication.activewindow.activepane.view.showfieldcodes = true; try {     _wordapplication.selection.insertformula("=1");                           _wordapplication.selection.moveleft(wdunits.wdcharacter, 1);     _wordapplication.selection.typetext("+");     var field =_wordapplication.activedocument.fields.add(_wordapplication.selection.range,   microsoft.office.interop.word.wdfieldtype.wdfieldempty, "page", true);     field.update();  }            {   _wordapplication.activewindow.activepane.view.showfieldcodes = false; } 

Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -