Printing macro

pincivma

Board Regular
Joined
Dec 12, 2004
Messages
206
Hi there
I'm not sure if this is possible or not to do in Excel. Is it possible for me to set up my printing options first and then run a macro to print out the data that I have chosen before hand. I could have chosen only a selection or the whole worksheet etc. I know that I can record a macro by setting up all of the possible printing options but I will have many macros to run, since I have many printing options available to me. What I want is to choose all of my printing options before I run my macro and the macro will somehow know which printing options I selected and print out the data.

Thanks
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
First create several subroutines like

Sub print_options_01 ()

With ActiveSheet.PageSetup
.CenterHorizontally = True
.CenterVertically = False
...
...
...
End With
End Sub

Then in the main sub the relevant print_option sub can be called upon using an IF-THEN-ELSE statement.

Hope this helps!
 
Upvote 0
Not just....

Code:
Sub Macro5()
    With ActiveSheet
        .PageSetup.PrintArea = Selection.Address
        .PrintOut
    End With
End Sub
 
Upvote 0
Hi Mark858

I tried your macro below and I got a real weird looking computer screen. The Excel spread sheet turned gray with the selection that I picked highlighted. I tried to undo the gray area but without success. I then clicked on print area and clear print area and all of my formatting was gone. Do you know why your code did that??

Thanks

Sub Macro5()
With ActiveSheet
.PageSetup.PrintArea = Selection.Address
.PrintOut
End With
End Sub
 
Upvote 0
No reason, that I can think of. There is nothing in the code that alters formatting.

All the code does is set the print area and print... exactly the same if you done it manually.

I have just ran the code 7 times on a sheet with both normal formatting and conditional formatting and the only things I got was the normal shading you get get from doing the manual selection and the dotted line showing the print area.

None of the formatting was affected.

Are any of your cells locked and the sheet protected?
 
Last edited:
Upvote 0
Possibly... but just stretching ideas at the moment.
Copy your workbook, then on the copy manually unprotect the sheet and test. Leave the cells as they are.
 
Upvote 0

Forum statistics

Threads
1,224,821
Messages
6,181,163
Members
453,021
Latest member
Justyna P

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