Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > VBA / Office Integration > Excel > Getting the number of pages printing would give


Reply
 
Thread Tools Display Modes
  #1  
Old 01-29-2004, 07:52 AM
burningice96's Avatar
burningice96 burningice96 is offline
Junior Contributor
 
Join Date: Apr 2003
Location: Montreal
Posts: 270
Default Getting the number of pages printing would give


Hey. Just trying to put the finishing touches on a little project at work. I've got a spreadsheet that prints to 11 x 17 paper. My boss wants me to write how many pages will be printed on the sheet somewhere, and I'm really not sure how to get that information. Any ideas?
Reply With Quote
  #2  
Old 01-29-2004, 07:58 AM
googootou googootou is offline
Newcomer
 
Join Date: Dec 2003
Posts: 12
Default

Quote:
Originally Posted by burningice96
Hey. Just trying to put the finishing touches on a little project at work. I've got a spreadsheet that prints to 11 x 17 paper. My boss wants me to write how many pages will be printed on the sheet somewhere, and I'm really not sure how to get that information. Any ideas?



If you go to File -> Page Setup -> Header / Footer -> In either the header or footer of the page you can show what page you're on, total pages, date, filename, and all that good stuff.
Reply With Quote
  #3  
Old 01-29-2004, 08:01 AM
burningice96's Avatar
burningice96 burningice96 is offline
Junior Contributor
 
Join Date: Apr 2003
Location: Montreal
Posts: 270
Default

Ok that's really cool. But what if I want to use that information in a specific place on the page (and not necessarily in the header). Is there a way I can extract that information?
Reply With Quote
  #4  
Old 01-29-2004, 08:27 AM
burningice96's Avatar
burningice96 burningice96 is offline
Junior Contributor
 
Join Date: Apr 2003
Location: Montreal
Posts: 270
Default

I made a macro to find out what the header does when I ask it to put up the page numbers and it gives me this:

Code:
With ActiveSheet.PageSetup .LeftHeader = "" .CenterHeader = "Page &P de &N"

And so on and so forth. But when I copy &P into text, it writes it as &P, and not the page number itself. Any thoughts?
Reply With Quote
  #5  
Old 01-29-2004, 09:54 AM
Kluz's Avatar
Kluz Kluz is offline
Sapience.Aquire

Super Moderator
* Expert *
 
Join Date: Oct 2003
Location: Lake Bluff, Ill., U.S.
Posts: 3,306
Default

There wasn't a cell function that I could find that would return the number of printable sheets, so I made one:
Code:
Public Function NumPage() As Long NumPage = (ActiveSheet.HPageBreaks.Count + 1) * (ActiveSheet.VPageBreaks.Count + 1) End Function
__________________
No the other right mouse click
Reply With Quote
  #6  
Old 02-05-2004, 06:51 AM
burningice96's Avatar
burningice96 burningice96 is offline
Junior Contributor
 
Join Date: Apr 2003
Location: Montreal
Posts: 270
Default

That's perfect Kluz. Thanks a bunch!
Reply With Quote
  #7  
Old 02-05-2004, 02:27 PM
Ivan F Moala's Avatar
Ivan F Moala Ivan F Moala is offline
Junior Contributor

* Expert *
 
Join Date: Dec 2002
Location: Auckland, New Zealand
Posts: 201
Default

Quote:
Originally Posted by burningice96
That's perfect Kluz. Thanks a bunch!



To get the number of pages to print then

Code:
Sub GetNoPgs_ToPrnt() Dim dPages As Double dPages = ExecuteExcel4Macro("GET.DOCUMENT(50)") MsgBox dPages & " Pages will be printed" End Sub
__________________
Ivan F Moala
Visit my Site
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
disable print preview from xlDialogPrint w_seyller Excel 9 12-11-2003 11:20 AM
How can I get CORRECT number of pages? DanZer Word, PowerPoint, Outlook, and Other Office Products 4 11-07-2003 07:43 AM
Change the number of pages jaurovi Word, PowerPoint, Outlook, and Other Office Products 0 07-07-2003 02:12 PM
Dynamically printing pages using an Excel macro PrivatePile Word, PowerPoint, Outlook, and Other Office Products 1 06-12-2003 01:57 PM
pacman ghost AI VB6Newbie Game Programming 23 10-10-2002 07:32 PM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->