說明:因爲業務需要,需要在Winform顯示Word文件,但是因爲Word的內容太多,則需要自動翻頁。
以下做一下記錄,以備後續查詢的需要。用的AxDSOFramer.AxFramerContro這個控件去顯示的Word。
翻頁的核心的代碼如下:
Microsoft.Office.Interop.Word.Document doc = (Microsoft.Office.Interop.Word.Document)axFramerControl1.ActiveDocument;
doc.Windows.Application.ActiveWindow.View.Zoom.Percentage = iPrecentage;
//顯示小翻頁,即只翻一個屏幕的內容
doc.Windows.Application.ActiveWindow.LargeScroll(1);
//顯示大翻頁,即翻一整頁的內容
//d.Windows.Application.ActiveWindow.PageScroll(1);
另外附上獲取Word頁數的方法:
object Nothing = System.Reflection.Missing.Value;
int iPageCount = doc.ComputeStatistics(Microsoft.Office.Interop.Word.WdStatistic.wdStatisticPages, ref Nothing);