Get Number of Pages in a Microsoft Word Document with vb.net

Good Morning! Last night I played with the band from Celebrate Recovery. It was okay considering we had never played together and I didn’t know the material. I am not usually in the habit of this, but hey its not rocket science we are doing here. And I only played bass on my keyboard which is pretty easy for me.

Today’s topic is how to get the number of pages in a Microsoft Word document with vb.net. Not complicated, but I was asked so here it is. Make it a great day!


Join me on Facebook

Function GetWordPages

Try
            word_server = New Word.Application
            Dim Doc As Word.Document
            Doc=word_server.Documents.Open(FilePath)
            return Doc.ComputeStatistics(wdStatisticPages)           
        Catch ex As Exception

        Finally
            word_server.Application.Quit()
            word_server = Nothing
        End Try

 

End Function


Join me on Facebook

Technorati Tags: ,,,,,,,,,
,,,,,,,,
,

Advertisements
  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: