WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

OLE with Word

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Get total number of pages

 Keywords: page count number pages  

Question:

Is there a way to open *.Doc file and determine how many pages are in the document?

Answer:

It turns out Word is bit complex...even www.microsoft.com didn't have object documentation on it.

After some poking around, it's property #14...



        Worddoc = ObjectOpen("Word.Application")
        WDOC = Worddoc.Application
        WDOC.visible = @false
        docname = "C:\Data\Word\Issue Mgmt Functional Design.doc"
        docs = WDOC.documents
        docs.open(docname)
        wsas = WDOC.activedocument

                bidp = wsas.builtindocumentproperties(14)

                pages = bidp.value

                message("Pages in %docname%", pages)

        docs.close
        WDOC.quit
        objectclose(wsas)
        objectclose(WDOC)
        objectclose(Worddoc)

 

Article ID:   W14935
File Created: 2001:11:08:12:41:00
Last Updated: 2001:11:08:12:41:00