ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Get number of pages to be printed - before print (https://www.excelbanter.com/excel-programming/343983-get-number-pages-printed-before-print.html)

Les Stout[_2_]

Get number of pages to be printed - before print
 
Hi all, is it at all possible to get the number of pages to be printed
with code before you actually print, a si would like to give the user a
warning of the number of pages to be printed & then perhaps an option of
the number of pages to be printed.


Thanks in advance,


Les Stout

*** Sent via Developersdex http://www.developersdex.com ***

Rody Meulman[_3_]

Get number of pages to be printed - before print
 
Solution from KeepItcool (from a Dutch tread):
tread: http://tinyurl.com/d827j

Sub PapierHier()
Const cFml = "GET.DOCUMENT(50,""&O"")"
Dim ws, n&, s$


With Application
For Each ws In ActiveWorkbook.Worksheets
n = .ExecuteExcel4Macro(.Substitute(cFml, "&O", ws.Name))
s = s & n & vbTab & ws.Name & vbNewLine
Next
End With


MsgBox sMsg
End Sub




Greetz,

Rody



"Les Stout" schreef in bericht
...
Hi all, is it at all possible to get the number of pages to be printed
with code before you actually print, a si would like to give the user a
warning of the number of pages to be printed & then perhaps an option of
the number of pages to be printed.


Thanks in advance,


Les Stout

*** Sent via Developersdex http://www.developersdex.com ***




Ron de Bruin

Get number of pages to be printed - before print
 
Hi Less

Dim TotPages As Long
TotPages = Application.ExecuteExcel4Macro("GET.DOCUMENT(50)")



--
Regards Ron de Bruin
http://www.rondebruin.nl


"Les Stout" wrote in message ...
Hi all, is it at all possible to get the number of pages to be printed
with code before you actually print, a si would like to give the user a
warning of the number of pages to be printed & then perhaps an option of
the number of pages to be printed.


Thanks in advance,


Les Stout

*** Sent via Developersdex http://www.developersdex.com ***




Tom Ogilvy

Get number of pages to be printed - before print
 
Demo'd from the immediate window:

? application.ExecuteExcel4Macro("Get.Document(50,"" Sheet1"")")
3

Usage

numPages = application.ExecuteExcel4Macro("Get.Document(50,"" Sheet1"")")


or for the activesheet

numpages = application.ExecuteExcel4Macro("Get.Document(50,)" )

--
Regards,
Tom Ogilvy



"Les Stout" wrote in message
...
Hi all, is it at all possible to get the number of pages to be printed
with code before you actually print, a si would like to give the user a
warning of the number of pages to be printed & then perhaps an option of
the number of pages to be printed.


Thanks in advance,


Les Stout

*** Sent via Developersdex http://www.developersdex.com ***




Les Stout[_2_]

Get number of pages to be printed - before print
 
Thanks Ron, works great, maar noch ein vraag. How do you know if it is
checking for portrait or landscape ?

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***

Les Stout[_2_]

Get number of pages to be printed - before print
 
Hi Tom & Ron, have answered my own question by trying it out, i see that
it takes whatever the printer setting you have used.
Just a further question is it the function (50)that tells it what to
look for ? If so, were can one get a list of functions that can be used
?

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***

Ron de Bruin

Get number of pages to be printed - before print
 
Hi Less

See
http://www.microsoft.com/downloads/d...DisplayLang=en


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Les Stout" wrote in message ...
Hi Tom & Ron, have answered my own question by trying it out, i see that
it takes whatever the printer setting you have used.
Just a further question is it the function (50)that tells it what to
look for ? If so, were can one get a list of functions that can be used
?

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***




Les Stout[_2_]

Get number of pages to be printed - before print
 
Dankie Ron lekker aand.

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***

Ron de Bruin

Get number of pages to be printed - before print
 
Graag gedaan

--
Regards Ron de Bruin
http://www.rondebruin.nl


"Les Stout" wrote in message ...
Dankie Ron lekker aand.

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***





All times are GMT +1. The time now is 01:05 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com