EDN Admin
Well-known member
I am reading http://support.microsoft.com/default.aspx?scid=kb;en-us;303294
I want to be able to use BuiltInDocumentProperties to find out the number of pages in a Word document.Dim oWord As Word.Application
Dim oDoc As Word.Document
oWord = New Word.Application
oWord.Visible = False
oDoc = oWord.Documents.Open("C:TestDataexample.docx")
Dim oBuiltInProps As Office.DocumentProperties
oBuiltInProps = CType(oDoc.BuiltInDocumentProperties, Office.DocumentProperties)
Debug.Print(oBuiltInProps.Item(WdBuiltInProperty.wdPropertyPages).Value.ToString())
oDoc.Close()
oWord.Quit()
oDoc = Nothing
oWord = Nothing
I get an error message at the CType.
If I declare
Dim oBuiltInProps As Object = oDoc.BuiltInDocumentProperties
Debug.Print(oBuiltInProps.Item(WdBuiltInProperty.wdPropertyPages).Value.ToString())
Then I get an error that Option Strict On disallows late binding and the squiggly line under oBuiltInProps.Item
How do I do this properly?
View the full article
I want to be able to use BuiltInDocumentProperties to find out the number of pages in a Word document.Dim oWord As Word.Application
Dim oDoc As Word.Document
oWord = New Word.Application
oWord.Visible = False
oDoc = oWord.Documents.Open("C:TestDataexample.docx")
Dim oBuiltInProps As Office.DocumentProperties
oBuiltInProps = CType(oDoc.BuiltInDocumentProperties, Office.DocumentProperties)
Debug.Print(oBuiltInProps.Item(WdBuiltInProperty.wdPropertyPages).Value.ToString())
oDoc.Close()
oWord.Quit()
oDoc = Nothing
oWord = Nothing
I get an error message at the CType.
If I declare
Dim oBuiltInProps As Object = oDoc.BuiltInDocumentProperties
Debug.Print(oBuiltInProps.Item(WdBuiltInProperty.wdPropertyPages).Value.ToString())
Then I get an error that Option Strict On disallows late binding and the squiggly line under oBuiltInProps.Item
How do I do this properly?
View the full article