LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel VBA: Setting PageSetup.TopMargin for _EACH_ page


Hello all,
This problem has been driving me crazy for hours. I have a simple excel
sheet with just 2 pages with about 50 rows. I want the first page to
have a special header which will take up a lot of space on the top. I
want the remaining pages without the header and normal page margins.
Since Excel does not provide a special "first page" setup, I am using a
macro that sets the header and the topmargin, prints the first page,
sets the header to blank and topmargin to a lesser value and prints the
rest of the pages. My code looks like this:

Dim sHeader as String
With wsSheet
sHeader = .PageSetup.CenterHeader
PageSetup.TopMargin = Application.InchesToPoints(2.5)
PrintOut From:=1, To:=1
PageSetup.CenterHeader = ""
PageSetup.HeaderMargin =
Application.InchesToPoints(1)
PrintOut From:=2
PageSetup.CenterHeader = sHeader
End With

What happens is really strange: when printing page 2, Excel thinks that
whole sheet has a top margin of 1 inch, and thus, prints nothing on the
second page, because if the top margin were 1 inch for page 1, all 50
rows would fit into 1 page and there is no second page. But that is not
true!!! It just printed page 1 with a topmargin of 2.5 inches so there
are more rows left to print.
I hope you understand my problem. Basically, I want to setup specific
topmargin values to _EACH_ page and it just isn't working.
Any help is appreciated,
Thanks!


--
breakfree
------------------------------------------------------------------------
breakfree's Profile: http://www.excelforum.com/member.php...o&userid=27806
View this thread: http://www.excelforum.com/showthread...hreadid=473145

 
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
recalculate page breaks after setting Zoom in pagesetup Par Excel Discussion (Misc queries) 3 June 21st 07 03:24 PM
PageSetup.LeftFooter only on last Page Andy Excel Worksheet Functions 3 December 6th 04 01:53 PM
Setting TopMargin Property in VBA John S.[_3_] Excel Programming 2 October 17th 03 06:08 PM
read ZOOM after setting FitToPagesWide in pagesetup Dave Peterson[_3_] Excel Programming 1 September 3rd 03 11:45 AM
read ZOOM after setting FitToPagesWide in pagesetup richard daniels Excel Programming 1 September 2nd 03 02:07 PM


All times are GMT +1. The time now is 11:35 PM.

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

About Us

"It's about Microsoft Excel"