Code not working for .PrintOut

iouu2

New Member
Joined
Apr 15, 2011
Messages
14
Hi. I made a command button that will print off tabs within a workbook. However, I am trying to make it so that this excel file can be print-ready, meaning everything is easy to read and doesn't flow into 3 pages when it can be condensed into one? The problem I am having is I want to make it so that the entire workbook is print-ready without having radio buttons for each Tab. Is this possible?


Have a command button called PrintTabs
Have radio buttons for various tabs called Tab1, Tab2, Tab3, Tab4, etc.
The Value field of Tab1 button as true. As you click on any other radio button, the value will cycle through the different buttons.

Double click on the command button the below code is inserted:
Private Sub PrintTabs_Click()
If Tab1.Value = True Then
Sheets("Tab 1").PrintOut
ElseIf Tab2.Value = True Then
Sheets("Tab 2").PrintOut
End If
End Sub


This is the code I was thinking for to make it print-ready and fit nicely, but need help executing code.


Private Sub Print_Macro()


ActiveWindow.View = xlPageBreakPreview
ActiveSheet.ResetAllPageBreaks
With ActiveSheet.PageSetup
.FooterMargin = Application.InchesToPoints(0.45)
.PrintTitleColumns = ""
End With
ActiveSheet.PageSetup.PrintArea = ""
With ActiveSheet.PageSetup
.LeftFooter = "&""SupportingEvidence"" & Chr(10)
.RightFooter = "Page: &P of &N "
.CenterFooter = "&R"
.Orientation = xlLandscape
.PaperSize = xlPaperLegal
'.FirstPageNumber = xlAutomatic
'.Order = xlDownThenOver
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = False

End With
ActiveWindow.View = xlNormalView
Range("A1").Select
End Sub
 
What do you mean by "help executing" the code? If that code is working as you want it to for a single page with the radio button, we can definitely help you execute it on each page in your workbook. If I was setting this up, I would remove the radio buttons and just add a shape with a macro assigned. The macro would be assigned to a helper function that would get the list of worksheets you want to execute this code on and pass each one individually into the code provided (with a few modifications). You could put the shape on all of your tabs or you could put it on a single tab; either way, clicking the button would prepare all the specified sheets for printing.

If this method seems like a good fit, you'd need to let us know if you planned to keep the .Printout functionality and, if so, how you wanted to select the sheet to print? With the method above, a shape could be put on each sheet and when clicked would only print that sheet or all sheets could be printed at once upon clicking the shape (or bound to Control+P to "hijack" the default print menu).

Give it a little more thought and let us know how you want to make this work :)
 
Upvote 0
This is the code I was thinking for to make it print-ready and fit nicely, but need help executing code


Could you not just put the code from the "Private Sub Print_Macro()" in the Workbook_BeforePrint event?
 
Upvote 0

Forum statistics

Threads
1,226,848
Messages
6,193,315
Members
453,790
Latest member
yassinosnoo1

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top