jazminecat23
Programmer
Hi all --
I have an Excel Spreadsheet that creates a bunch of other spreadsheets and saves them off every month. This all happens with a button click. It works fabulously, thanks in large part to the help I've gotten here. I now have requests from end users to setup the document print specifications. Note: Because the spreadsheets the users receive are generated from the master, and not just copies of the master, they don't have the same page setup parameters that the master has.
So I need to access the page setup for each one as it's created, and then move on to the next part step in the code. I used the macro recorder to record the code below, step 7a. I included the code before and after this bit so you can see what's happening - the other steps work perfectly - it's only 7a that I'm trying to make happen. Right now, what happens, is it does open the page setup window....and then it sits there waiting for me to close it. Because this master spreadsheet is used to create over 250 spreadsheets every month, having to close that window is really counterproductive - so I need it to close the window and continue on with the next step in the code. Anyone got any insight here?
So what happens in the above code is it gets to the end of step 7a, and just sits there waiting for me to close the print preview window (even though I didn't stop recording the macro until I'd done that). Once I click close, it moves on to step 8 and continues with the rest of the code just fine.
Thanks again for all your help!
I have an Excel Spreadsheet that creates a bunch of other spreadsheets and saves them off every month. This all happens with a button click. It works fabulously, thanks in large part to the help I've gotten here. I now have requests from end users to setup the document print specifications. Note: Because the spreadsheets the users receive are generated from the master, and not just copies of the master, they don't have the same page setup parameters that the master has.
So I need to access the page setup for each one as it's created, and then move on to the next part step in the code. I used the macro recorder to record the code below, step 7a. I included the code before and after this bit so you can see what's happening - the other steps work perfectly - it's only 7a that I'm trying to make happen. Right now, what happens, is it does open the page setup window....and then it sits there waiting for me to close it. Because this master spreadsheet is used to create over 250 spreadsheets every month, having to close that window is really counterproductive - so I need it to close the window and continue on with the next step in the code. Anyone got any insight here?
Code:
[green] this works just perfectly [/green]
'7. Replace formulas with values in new workbook
For Each ws In wbNew.Worksheets
ws.Cells.Copy
ws.Cells.PasteSpecial xlPasteValues
ws.Activate
ws.Cells(1, 1).Select
Next
[green]this is what I am trying to make work [/green]
[red]
'New 6/27/07
'7a. Setup sheet to print landscape 1 page wide, unspecified pages long
With wbNew
.Sheets("BudgetStatus").PageSetup
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperLetter
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = False
End With
ActiveWindow.SelectedSheets.PrintPreview
[/red]
[green]this also works fine - when I don't have the above code in the module[/green]
'8. save and close new workbook
With wbNew
.Sheets("BudgetStatus").Select
.SaveAs "I:\SpreadsheetServer\Month End Reports" & "\" & sName & ".xls"
.Close
End With
Next
So what happens in the above code is it gets to the end of step 7a, and just sits there waiting for me to close the print preview window (even though I didn't stop recording the macro until I'd done that). Once I click close, it moves on to step 8 and continues with the rest of the code just fine.
Thanks again for all your help!