I created a new macro to format a page to US Letter and print 1 page wide and 1 page tall, then print. All works fine, but it prints 5 copies. I have made two different named macros and they both do the same thing. Help?!![]()
I created a new macro to format a page to US Letter and print 1 page wide and 1 page tall, then print. All works fine, but it prints 5 copies. I have made two different named macros and they both do the same thing. Help?!![]()
Why dont you post your code here?
If I have helped, Don't forget to add to my reputation (click on the star below the post)
Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
Use code tags when posting your VBA code: [code] Your code here [/code]
I am not sure what you mean by "my code".... I used mouse clicks to record the macros... ?
Yes, the same code. You can post it here and we can help you with it.
OK, well.... I started by clicking on Tools, then the drop down to Macros, then Record new Macro. From there, I named my Macro, then in the box for the shortcut key, I put an "p" and clicked OK.
I immediately went to File > Print > Page setup > Options > changed the paper size to Letter > OK > clicked "Fit to 1 page wide by 1 page tall > Print.
Then I went back to Tools > Stop Recording Macro.
When I press Option + Command + p, it does it's thing and prints 5 copies.
Is that what you wanted to know?
In order to solve your problem. We need code.
Press ALT+F11 --> click module -----you can see some codes ----copy that codes ----- post to this thread
Oh, see that is what I didn't know. OK, I think this is what you want:
![]()
Sub formatandprint() ' ' formatandprint Macro ' format to letter size, then print ' ' Keyboard Shortcut: Option+Cmd+p ' ActiveWindow.SelectedSheets.PrintOut From:=1, To:=1, Copies:=1 ActiveWindow.SelectedSheets.PrintOut From:=1, To:=1, Copies:=1 With ActiveSheet.PageSetup .PrintTitleRows = "" .PrintTitleColumns = "" End With ActiveSheet.PageSetup.PrintArea = "" With ActiveSheet.PageSetup .LeftHeader = "&""Calibri,Regular""&K000000Cash Flow" .CenterHeader = "" .RightHeader = "&""Calibri,Regular""&K000000&D" .LeftFooter = "" .CenterFooter = "" .RightFooter = "" .LeftMargin = Application.InchesToPoints(0.25) .RightMargin = Application.InchesToPoints(0.25) .TopMargin = Application.InchesToPoints(0.5) .BottomMargin = Application.InchesToPoints(0.5) .HeaderMargin = Application.InchesToPoints(0.5) .FooterMargin = Application.InchesToPoints(0.5) .PrintHeadings = False .PrintGridlines = False .PrintComments = xlPrintNoComments .PrintQuality = -4 .CenterHorizontally = False .CenterVertically = False .Orientation = xlPortrait .Draft = False .PaperSize = xlPaperLetter .FirstPageNumber = xlAutomatic .Order = xlDownThenOver .BlackAndWhite = False .Zoom = False .FitToPagesWide = 1 .FitToPagesTall = 1 End With ActiveWindow.SelectedSheets.PrintOut From:=1, To:=1, Copies:=1 ActiveWindow.SelectedSheets.PrintOut From:=1, To:=1, Copies:=1 ActiveWindow.SelectedSheets.PrintOut Copies:=1 ActiveWorkbook.Save End Sub
Last edited by Cutter; 09-20-2012 at 07:42 PM. Reason: Added code tags
try this.
![]()
Sub formatandprint() ' ' formatandprint Macro ' format to letter size, then print ' ' Keyboard Shortcut: Option+Cmd+p ' With ActiveSheet.PageSetup .PrintTitleRows = "" .PrintTitleColumns = "" End With ActiveSheet.PageSetup.PrintArea = "" With ActiveSheet.PageSetup .LeftHeader = "&""Calibri,Regular""&K000000Cash Flow" .CenterHeader = "" .RightHeader = "&""Calibri,Regular""&K000000&D" .LeftFooter = "" .CenterFooter = "" .RightFooter = "" .LeftMargin = Application.InchesToPoints(0.25) .RightMargin = Application.InchesToPoints(0.25) .TopMargin = Application.InchesToPoints(0.5) .BottomMargin = Application.InchesToPoints(0.5) .HeaderMargin = Application.InchesToPoints(0.5) .FooterMargin = Application.InchesToPoints(0.5) .PrintHeadings = False .PrintGridlines = False .PrintComments = xlPrintNoComments .PrintQuality = -4 .CenterHorizontally = False .CenterVertically = False .Orientation = xlPortrait .Draft = False .PaperSize = xlPaperLetter .FirstPageNumber = xlAutomatic .Order = xlDownThenOver .BlackAndWhite = False .Zoom = False .FitToPagesWide = 1 .FitToPagesTall = 1 End With ActiveWindow.SelectedSheets.PrintOut Copies:=1 ActiveWorkbook.Save End Sub
Last edited by thameem127; 09-20-2012 at 04:49 PM. Reason: remove codes
@ tamalloni
Welcome to the forum.
Please notice that code tags have been added to your post(s). The forum rules require them so please keep that in mind and add them yourself whenever showing code in any of your future posts. To see instructions for applying them, click on the Forum Rules button at the top of the page and read Rule #3.
Thanks.
@Thameem127
Thank you, I tried this and now it prints only two copies.
@Cutter
OK, Sorry, I am new to this forum and was not aware. I will do that in the future. Thank you.
Can you again please upload the Code you are now using that prints 2 copies?
Please consider:
Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .
Winon, were you going to suggest a new code?
@ Thameem127, I am new to this site, can you tell me how to mark is as solved?
I think it should print twice as you instructed it to do so.![]()
ActiveWindow.SelectedSheets.PrintOut From:=1, To:=1, Copies:=1 ActiveWindow.SelectedSheets.PrintOut Copies:=1
Delete the 2nd of the above lines and it should just print one page.
Also, search for "cleaning code generated by macro recorder"
You can shorten the code considerably and the bonus will be that you'll learn about coding.
Hi Winon, here you go:
![]()
Sub formatandprint() ' ' formatandprint Macro ' format to letter size, then print ' ' Keyboard Shortcut: Option+Cmd+p ' With ActiveSheet.PageSetup .PrintTitleRows = "" .PrintTitleColumns = "" End With ActiveSheet.PageSetup.PrintArea = "" With ActiveSheet.PageSetup .LeftHeader = "&""Calibri,Regular""&K000000Cash Flow" .CenterHeader = "" .RightHeader = "&""Calibri,Regular""&K000000&D" .LeftFooter = "" .CenterFooter = "" .RightFooter = "" .LeftMargin = Application.InchesToPoints(0.25) .RightMargin = Application.InchesToPoints(0.25) .TopMargin = Application.InchesToPoints(0.5) .BottomMargin = Application.InchesToPoints(0.5) .HeaderMargin = Application.InchesToPoints(0.5) .FooterMargin = Application.InchesToPoints(0.5) .PrintHeadings = False .PrintGridlines = False .PrintComments = xlPrintNoComments .PrintQuality = -4 .CenterHorizontally = False .CenterVertically = False .Orientation = xlPortrait .Draft = False .PaperSize = xlPaperLetter .FirstPageNumber = xlAutomatic .Order = xlDownThenOver .BlackAndWhite = False .Zoom = False .FitToPagesWide = 1 .FitToPagesTall = 2 End With ActiveWindow.SelectedSheets.PrintOut From:=1, To:=1, Copies:=1 ActiveWindow.SelectedSheets.PrintOut Copies:=1 ActiveWorkbook.Save End Sub
Last edited by Cutter; 09-21-2012 at 09:18 PM. Reason: Fixed CODE tags
@ tamalloni
Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED. I'll do that for you now but please keep in mind for your future threads that Rule #9 requires you to do that yourself. If your problem has not been solved you can use Thread Tools (located above your first post) and choose "Mark this thread as unsolved".
Thanks.
Also, as a new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.
The reason I never marked it as solved was because "Winon" had asked me to post the code that was printing two copies, which I did, and I assumed he/she would have replied with another solution. Ultimately, I only want one page to print, not two. So technically it is not solved. But it's ok. Thank you all for your help.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks