Using MSWord = Microsoft. Office. InterOP. word;
Private MSWord. Application wordapp; // word ApplicationProgramVariable
Private MSWord. Document worddoc; // Word document variable
Private object nothing = missing. value;
// Initialization
Wordapp = new MSWord. applicationclass ();
Worddoc = wordapp. Documents. Add (ref nothing, ref nothing );
// Open Word
Object filename = strpath;
Object readonly = false;
Object isvisible = true;
Worddoc = wordapp. Documents. Open (ref filename, ref nothing, ref readonly,
Ref nothing, ref nothing,
Ref nothing, ref isvisible, ref nothing,
Ref nothing, ref nothing, ref nothing );
// Calculate the number of pages in a Word document
MSWord. wdstatistic stat = MSWord. wdstatistic. wdstatisticpages;
Int num = worddoc. computestatistics (stat, ref nothing );
// Jump to the specified bookmarks
Object bookmarkname = "bookmark1 ";
Object what = MSWord. wdgotoitem. wdgotobookmark;
Worddoc. activewindow. selection. Goto (ref what, ref nothing, ref nothing, ref bookmarkname );
MessageBox. Show (worddoc. activewindow. selection. Paragraphs [1]. range. Text. tostring ());
// Jump to the specified page
Object what = MSWord. wdgotoitem. wdgotopage;
Object which = MSWord. wdgotodirection. wdgotonext;
Object Name = "1"; // Number of pages
Worddoc. activewindow. selection. Goto (ref what, ref which, ref nothing, ref name); // The second parameter can use nothing
Worddoc. activewindow. selection. Paragraphs [1]. range. Text. tostring ();
// The following operations are performed after a page is jumped.
// You can use pagesetup to obtain information about a page.
// Retrieve the column of the page
Worddoc. activewindow. selection. pagesetup. textcolumn;