Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Number of pages

Hello,

I need to find out how many pages does a sheet contain
(can be 1 or 2 pages only), before sending the following
line: sheet.PrintPreview, ex

PageNum = sheet.Number_Of_Pages_To_Be_Printed
if PageNum = 1 then
sheet.PrintPreview
else
alert user
end if

This will print a 1 page list, if the number of items
exceeds the 1st page, the printing has to be cancelled

Thanks in advance!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 227
Default Number of pages

Hi fernando

'Place in "ThisWorkbook" module
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Cancel = True
HowManyPages
End Sub


'Place in a "General" module
Sub HowManyPages()
Dim Cmd As String
Cmd = "GET.DOCUMENT(50,""" & ActiveSheet.Name & """)"
If Application.ExecuteExcel4Macro(Cmd) = 1 Then
Application.EnableEvents = False
ActiveSheet.PrintPreview
Application.EnableEvents = True
Else
MsgBox "Too many sheets"
End If
End Sub


--
XL2002
Regards

William



"fernando" wrote in message
...
| Hello,
|
| I need to find out how many pages does a sheet contain
| (can be 1 or 2 pages only), before sending the following
| line: sheet.PrintPreview, ex
|
| PageNum = sheet.Number_Of_Pages_To_Be_Printed
| if PageNum = 1 then
| sheet.PrintPreview
| else
| alert user
| end if
|
| This will print a 1 page list, if the number of items
| exceeds the 1st page, the printing has to be cancelled
|
| Thanks in advance!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Number of pages

Try this:

If you want to make sure that each and every time you print, only 1 page is
used, go to: File | Page setup.

In the "Page" tab, choose to scale to 1 page in width and remove the 1 in
the height box.

Pierre


"fernando" a écrit dans le message de
...
Hello,

I need to find out how many pages does a sheet contain
(can be 1 or 2 pages only), before sending the following
line: sheet.PrintPreview, ex

PageNum = sheet.Number_Of_Pages_To_Be_Printed
if PageNum = 1 then
sheet.PrintPreview
else
alert user
end if

This will print a 1 page list, if the number of items
exceeds the 1st page, the printing has to be cancelled

Thanks in advance!



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Number of pages

Thanks
-----Original Message-----
Hi fernando

'Place in "ThisWorkbook" module
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Cancel = True
HowManyPages
End Sub


'Place in a "General" module
Sub HowManyPages()
Dim Cmd As String
Cmd = "GET.DOCUMENT(50,""" & ActiveSheet.Name & """)"
If Application.ExecuteExcel4Macro(Cmd) = 1 Then
Application.EnableEvents = False
ActiveSheet.PrintPreview
Application.EnableEvents = True
Else
MsgBox "Too many sheets"
End If
End Sub


--
XL2002
Regards

William



"fernando" wrote

in message
...
| Hello,
|
| I need to find out how many pages does a sheet contain
| (can be 1 or 2 pages only), before sending the

following
| line: sheet.PrintPreview, ex
|
| PageNum = sheet.Number_Of_Pages_To_Be_Printed
| if PageNum = 1 then
| sheet.PrintPreview
| else
| alert user
| end if
|
| This will print a 1 page list, if the number of items
| exceeds the 1st page, the printing has to be cancelled
|
| Thanks in advance!


.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Number of pages in worksheet doesn't match Print Preview pages delru Excel Discussion (Misc queries) 2 May 10th 10 10:08 PM
Auto Number Several Pages Gladys Excel Discussion (Misc queries) 1 January 11th 07 04:33 PM
How can I number pages so it changes every 3 pages? tina Excel Discussion (Misc queries) 0 February 16th 06 12:28 AM
Number of pages Pat Excel Worksheet Functions 1 January 31st 06 02:10 PM
How do i number pages in a header consequently JRD Excel Worksheet Functions 2 January 23rd 05 05:07 PM


All times are GMT +1. The time now is 03:06 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"