Dim num As Integer = 0
Dim fileName__2 As Object = FileName__1
Dim [readOnly] As Object = False
Dim isVisible As Object = True
Dim objDNS As Object = Word.WdSaveOptions.wdDoNotSaveChanges
Try
Dim WordApp As New Word.Application
' give any file name of your choice.
' the way to handle parameters you don't care about in .NET
Dim missing As Object = System.Reflection.Missing.Value
' Make word visible, so you can see what's happening
'WordApp.Visible = true;
' Open the document that was chosen by the dialog
Dim aDoc As Word.Document = WordApp.Documents.Open(fileName__2, missing, [readOnly], missing, missing, missing, _
missing, missing, missing, missing, missing, isVisible, _
missing, missing, missing, missing)
Dim stat As Word.WdStatistic = Word.WdStatistic.wdStatisticPages
num = aDoc.ComputeStatistics(stat, missing)
WordApp.Quit(objDNS, missing, missing)
aDoc = Nothing
WordApp = Nothing
GC.Collect()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Return num
End Function