Selection.Information

B

Brad

Hi,

I am using the following to get the number of pages there
are in a Word document (from within Excel). I can also use
it directly in Word without the "appWrd ".

Dim EndPage as Integer
EndPage = appWrd.Selection.Information
(wdNumberOfPagesInDocument)

This works sometimes, but the other times I get the error
message "Run Time Error 91 Object Variable or With Block
Variable not Set".

Is there something additional I need to do so I do not get
this error? I do not understand why it works sometimes but
not all the times.

THANKS!
 
G

Greg

Brad,

Maybe a variation of:

Dim EndPage As Long
EndPage = ActiveDocument.ComputeStatistics(wdStatisticPages)
would work better.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top