I know in VBA, within a document, I can get page count using ActiveDocument.Range.Information(wdNumberOfPagesInDocument), But I can't find an equivalent of it in VB.Net using Microsoft.Office.Interop.Word.
Is there, perhaps another way I can attain the quantity of pages in a document?
Public Class Window
'set form level declarations
Dim appPath As String
Dim objWordApp As New Word.Application
Dim objDoc As Word.Document
Dim errorPosition As String
Private Sub Window_Load(ByVal sender As System.Object, e As System.EventArgs) Handles MyBase.Load
objDoc = objWordApp.ActiveDocument
With objDoc
pages = .ActiveDocument.Range.Information(wdNumberOfPagesInDocument)
End With
objDoc = Nothing
End Sub
objWordApp = Nothing
End Class
Microsoft.Office.Interopnamespace reflects the API provided by Office VBA (as close as possible), so basically anything that is possible in VBA can also be done in .NET using theMicrosoft.Office.Interopnamespace. Where exactly are you stuck / having problems with? Is it getting theActiveDocument? In that case: You can get theActiveDocumentfrom theWord.Applicationclass. - bassfaderpages = .Application.ActiveDocument.Range.Information(Word.WdInformation.wdNumberOfPagesInDocument)- addohmpages = objDoc.ComputeStatistics(WdStatistic.wdStatisticPages, False), give that a shot... - Trevor