rtf文檔由數據庫應用程序生成,其中包含來自此數據庫的信息。我創建了一個軟件(C#,net framework 4.5),來獲取數據,然後將其記錄到Excel文件中。頁腳讀取後仍然有效(rtf公式文件)
我必須閱讀rtf文件的頁腳,我可以做的事情。
但是,當軟件訪問頁腳時,文檔視圖在頁腳/頁頭處於活動狀態時是相同的(當您在Word下雙擊頁眉/頁腳訪問頁面時,效果相同。在頭回車(Word加載該進入的東西),這\ r會使有額外的頁面
下面的代碼:
Sections oSection = cGlobalVar.varWordApp.ActiveDocument.Sections;
HeaderFooter oFooter = oSection[1].Footers[WdHeaderFooterIndex.wdHeaderFooterFirstPage];
Range oRange = oFooter.Range.Tables[1].Range;//<= at this point, footer is accessible, the empty header of original document has a\r character, causing 2nd page to document that I don't want
strBuffer = oRange.Text;//<= information I need
oRange = oSection[1].Range.Tables[1].Range;//<= try to affect something else to oRange
oFooter = null;//<= try to null the object
oSection = null;//<= same as above
//cGlobalVar.varWordDoc.ActiveWindow.View.Type = WdViewType.wdPrintView;//<= try to use this to return to a normal state
我試圖操縱Word中找到的東西找回到我的原始文檔(一頁),但沒有任何成功。
不客氣。此外,由於您是StackOverflow的新用戶,因此我想告訴您,您可以通過查看答案旁邊的勾號來獲得最佳答案並接受最能幫助您的答案。在這個網站上upvote或接受的答案算作「謝謝」。 –