Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Formating Print Margins

Ok I know this code is wrong and correct to an extent. On first run (on
any particular sheet) it come up with an error on the SET and just
breaks the page into 3. on the second run it sets the page breaks.

pretty much what i am tring to do is get it so this macro will be
assigned to a buttn you press the button and regardless of what the
users have done to the print layout it will set it to 3 pages high with
the pages breaks in the correct places.

Sub actuals()

Sheet12.PageSetup.PrintArea = "$A$1:$AQ$215"
With Sheet12.PageSetup
.FitToPagesWide = 1
.FitToPagesTall = 3
End With
Sheet12.ResetAllPageBreaks

Sheet12.HPageBreaks(1).Location = Range("A68", "A141")
Sheet12.HPageBreaks(2).Location = Range("A141", "A215")

Set Sheet12.HPageBreaks(1).Location = Range("A68", "A141")
Set Sheet12.HPageBreaks(2).Location = Range("A141", "A215")

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 162
Default Formating Print Margins

I got a similar result using your code. I got an error on the first Set
Sheet12... line.

Then I modified it as shown below by adding page breaks instead of
settings them, but I still couldn't get it to work. The weird thing is,
I recorded a macro with all the steps and got it to work. When I
manually reset the print area and reset the page breaks, then ran the
macro, I got a big fat nothing. It didn't set the page breaks at all.
Looks like a bug.

' This doesn't work
Sub SetPageBreaks()

Dim ws As Worksheet

Set ws = Application.Sheets("Sheet1")
With ws
With .PageSetup
.PrintArea = "$A$1:$AQ$215"
.FitToPagesWide = 1
.FitToPagesTall = 3
End With
.ResetAllPageBreaks
.HPageBreaks.Add .Range("A68")
.HPageBreaks.Add .Range("A141")

End With
Set ws = Nothing

End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Formating Print Margins

whats weirder with mine is if you run it the first time u get error -
run it again everything snaps to the right places LOL

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
Margins & print preview Meebers Excel Worksheet Functions 1 August 9th 07 10:38 PM
Print Blank Pgs - Preview margins outside print range dsm Excel Discussion (Misc queries) 0 October 25th 06 06:17 PM
How do I change print margins? BuniDyck Excel Discussion (Misc queries) 1 December 9th 05 02:46 PM
Excel Print Margins Adam S. Setting up and Configuration of Excel 2 October 25th 05 12:14 AM
Print margins on forms lchu80 Excel Discussion (Misc queries) 1 December 8th 04 11:01 PM


All times are GMT +1. The time now is 06:52 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"