Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XL: Error setting print area + multiple ranges by VBA

Status
Not open for further replies.

01Patrik

Technical User
Mar 29, 2004
243
SE
Hi,

I'm confused. I can't get XL to programatically set the print on a sheet to the mulitple ranges that I have as a print area on another sheet!

Now normally I'd use

Code:
    With ActiveSheet.PageSetup
        .PrintTitleRows = "$1:$5"
        .PrintTitleColumns = "$A:$F"
        .FitToPagesWide = 1
        .FitToPagesTall = 1
    End With

    ActiveSheet.PageSetup.PrintArea = "$G$7:$L$50;$G$52:$L$103;$N$7:$S$50;$N$52:$S$103;$U$7:$Z$50;$U$52:$Z$103;$AB$7:$AG$50;$AB$52:$AG$103;$AI$7:$AN$50;$AI$52:$AN$103"

...but that isn't working.

If I capture the multiple range by recording the print setup on then other sheet - like below:

Code:
    With ActiveSheet.PageSetup
        .PrintTitleRows = "$1:$5"
        .PrintTitleColumns = "$A:$F"
    End With
    ActiveSheet.PageSetup.PrintArea = "$G$7:$L$50;$G$52:$L$103;$N$7:$S$50;$N$52:$S$103;$U$7:$Z$50;$U$52:$Z$103;$AB$7:$AG$50;$AB$52:$AG$103;$AI$7:$AN$50;$AI$52:$AN$103"

    With ActiveSheet.PageSetup
        .LeftHeader = ""
        .CenterHeader = ""
        .RightHeader = ""
        .LeftFooter = ""
        .CenterFooter = ""
        .RightFooter = ""
        .LeftMargin = Application.InchesToPoints(0.78740157480315)
        .RightMargin = Application.InchesToPoints(0.78740157480315)
        .TopMargin = Application.InchesToPoints(0.984251968503937)
        .BottomMargin = Application.InchesToPoints(0.984251968503937)
        .HeaderMargin = Application.InchesToPoints(0.511811023622047)
        .FooterMargin = Application.InchesToPoints(0.511811023622047)
        .PrintHeadings = False
        .PrintGridlines = False
        .PrintComments = xlPrintNoComments
        .PrintQuality = 600
        .CenterHorizontally = True
        .CenterVertically = False
        .Orientation = xlLandscape
        .Draft = False
        .PaperSize = xlPaperA4
        .FirstPageNumber = xlAutomatic
        .Order = xlDownThenOver
        .BlackAndWhite = False
        .Zoom = False
        .FitToPagesWide = 1
        .FitToPagesTall = 1
        .PrintErrors = xlPrintErrorsDisplayed
    End With

...then one would think that would work. But nooo.


The reason I need this is to transfer the pretty complex report print structure to text-copies of the file.

Any ideas?

(Yes - I'm posting this in VBA as well, sorry for doubling but I'm really frustrated)

// Patrik
______________________________

To the optimist, the glass is half full. To the pessimist, the glass is half empty. To the IT Professional, the glass is twice as big as it needs to be.
 
Solution found in the VBA forum - simply using "," instead of ";" did the trick. Stupid really, since the multiple range was captured by recording a macro, but still... regional settings messed things up.

Thanks to MJPPaba in thread707-1013322


// Patrik
______________________________

To the optimist, the glass is half full. To the pessimist, the glass is half empty. To the IT Professional, the glass is twice as big as it needs to be.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top