最后,为了得到我想要的,我也投降了,
在下面的源代码中,它获取总页数、总图像数、纸张方向等,它扫描了整个ms word的页面。
我想要的是:
假设 document1.docx 有 5 页
如果用户想从页面范围 1,3,5 开始扫描页面,则绕过 SO 2,4。
我将如何在代码中执行此操作?
''GET msword documents
Private Function GetWordFile(ByRef pNumbers As Integer) As Boolean
Try
Dim WordApp As New Word.Application
Dim aDoc As Word.Document = WordApp.Documents.Open(PathnFileName, m, m, m, m, m, _
m, m, m, m, m, True, m, m, m, m)
''TO GET THE CHARACTERS COUNT OR BLANK PAGE
''Dim BlankPage as integer = aDoc.Content.Characters.Count
''Add a page numbers
'aDoc.Sections(1).Footers(1).PageNumbers.Add(1)
''Delete the page numbers
'aDoc.Sections(1).Footers(1).PageNumbers(1).Delete()
''GET NUMBER OF PAGES
'pNumbers = WordApp.Selection.Information(Word.WdInformation.wdActiveEndPageNumber)
pNumbers = aDoc.ComputeStatistics(Word.WdStatistic.wdStatisticPages, m)
''Code to get number of images...here.
''Code to get paper abouts... here.
aDoc.Close(Word.WdSaveOptions.wdSaveChanges, m, m)
FinalReleaseAnyComObject(aDoc)
End SyncLock
WordApp.Quit(m, m, m)
FinalReleaseAnyComObject(WordApp)
End SyncLock
GC.Collect()
GC.WaitForPendingFinalizers()
Return True
Catch ex As Exception
GC.Collect()
GC.WaitForPendingFinalizers()
Return False
End Try
End Function
谢谢,我希望有人以前经历过。