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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PrintPreview in VBA - not returning to worksheet

Status
Not open for further replies.

t16turbo

Programmer
Mar 22, 2005
315
GB
I have some code in my VBA that I recorded.
It fits my worksheet on 1 page, landscape.


when the VBA runs, it does this part of it, but keeps the print preview screen open - meaning that I have to manually press 'close' for it to carry on with the rest of the VBA code.

does anyone know why this is?

my code is here:
Code:
 With ActiveSheet.PageSetup
        .LeftHeader = ""
        .CenterHeader = ""
        .RightHeader = ""
        .LeftFooter = ""
        .CenterFooter = ""
        .RightFooter = ""
        .LeftMargin = Application.InchesToPoints(0.75)
        .RightMargin = Application.InchesToPoints(0.75)
        .TopMargin = Application.InchesToPoints(1)
        .BottomMargin = Application.InchesToPoints(1)
        .HeaderMargin = Application.InchesToPoints(0.5)
        .FooterMargin = Application.InchesToPoints(0.5)
        .PrintHeadings = False
        .PrintGridlines = False
        .PrintComments = xlPrintNoComments
        .PrintQuality = 600
        .CenterHorizontally = False
        .CenterVertically = False
        .Orientation = xlLandscape
        .Draft = False
        .PaperSize = xlPaperA4
        .FirstPageNumber = xlAutomatic
        .Order = xlDownThenOver
        .BlackAndWhite = False
        .Zoom = False
        .FitToPagesWide = 1
        .FitToPagesTall = 1
    End With
    ActiveWindow.SelectedSheets.printpreview
    Columns("D:P").Select
    Selection.ColumnWidth = 13.5
    ActiveWindow.SelectedSheets.printpreview
 
Don't go into PrintPreview is the answer! Why do you feel it necessary to go into PrintPreview?

Cheers, Glenn.

Did you hear about the literalist show-jumper? He broke his nose jumping against the clock.
 
I just recorded a macro of the usual way i set up the page... and then used the code.

i've removed the references to print preview and its fine now.

thanks!! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top