Я использую следующий код для доступа к страницам файлов слов. но у меня есть ошибка при попытке доступа к странице 2 (pg [2]) или (pg [0]) ... Я просто могу получить доступ к pg [1]! когда я пытаюсь получить доступ к другим страницам я получаю эту ошибку: The requested member of the collection does not exist.
только первая страница доступна в Microsoft.Office.Interop.Word
Word._Application oWord = new Word.Application();
// Make this instance of word invisible (Can still see it in the taskmgr).
oWord.Visible = false;
// Interop requires objects.
object oMissing = System.Reflection.Missing.Value;
// Load a document into our instance of word.exe
Word.Document oDoc = oWord.Documents.Open(ref fileName, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
// Make this document the active document.
oDoc.PrintPreview();
oDoc.Activate();
foreach (Microsoft.Office.Interop.Word.Window window in oDoc.Windows)
{
foreach (Microsoft.Office.Interop.Word.Pane pan in window.Panes)
{
Microsoft.Office.Interop.Word.Pages pg = pan.Pages;
Microsoft.Office.Interop.Word.Page pg1 = pg[1];
Microsoft.Office.Interop.Word.Page pg2 = pg[2];
}
}
oWord.Visible = true; // что бы это заставило его работать – zeta