Share via

Excel VBA Print Setup

Anonymous
2016-08-09T06:21:13+00:00

I am currently trying to set up a VBA that automatically takes data in a very simple format and then turns it into a properly formatted sheet that can just be printed, however anyway that I try to configure the print setup it doesnt seem to do anything when I go into the print preview and instaed seems to print it at about 10% zoom level, even though I have this disabled. The print setup was seemingly working until I updated the macro to include a header and footer in the formatting so I'm not sure what is causing it.

The code is as follows:

    ws.Worksheets(1).PageSetup.RightHeaderPicture.Filename = Range("K1").value

    ws.Worksheets(1).PageSetup.RightFooter = "Page &P of &N"

    ws.Worksheets(1).PageSetup.LeftFooter = " " 'Document

    ws.Worksheets(1).PageSetup.CenterFooter = "DOCUMENT NOT CONTROLLED IF PRINTED"

    With ws.Worksheets(1).PageSetup

        .RightHeader = "&G"

        .Zoom = 10

    End With

    ws.Worksheets(1).PageSetup.LeftHeader = " " 'Document

    With ws.Worksheets(1).PageSetup.RightHeaderPicture

        .Height = 54

        .Width = 103.5

    End With

    With ws.Worksheets(1).PageSetup

        .PrintArea = "$A$1:$I$" & row2 + 1    'Print Area setup

        .PrintTitleRows = "$8:$15"

        .Zoom = False

        .FitToPagesWide = 1

        .FitToPagesTall = False

    End With

This includes both the header & footer and the print setup script.

Thanks in Advance,

Will

Using Excel 2007

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

OssieMac 48,001 Reputation points Volunteer Moderator
2016-08-09T07:24:22+00:00

seems to print it at about 10% zoom level, even though I have this disabled.

The code is as follows:

    ws.Worksheets(1).PageSetup.RightHeaderPicture.Filename = Range("K1").value

    ws.Worksheets(1).PageSetup.RightFooter = "Page &P of &N"

    ws.Worksheets(1).PageSetup.LeftFooter = " " 'Document

    ws.Worksheets(1).PageSetup.CenterFooter = "DOCUMENT NOT CONTROLLED IF PRINTED"

    With ws.Worksheets(1).PageSetup

        .RightHeader = "&G"

        .Zoom = 10

    End With

    ws.Worksheets(1).PageSetup.LeftHeader = " " 'Document

    With ws.Worksheets(1).PageSetup.RightHeaderPicture

        .Height = 54

        .Width = 103.5

    End With

    

You have Zoom = 10. See bold print above.

Was this answer helpful?

0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2016-08-09T13:19:06+00:00

    Thanks! I must have thought that the .zoom variable was for the header picture and not the actual print size.

    Was this answer helpful?

    0 comments No comments