Best Microsoft Excel Bloggers

Thursday, September 29, 2011

Print Macro

I don't know about you but I am tired of always having to change my spreadsheet to a landscape orientation before printing. Personally, I think Microsoft should have made the default oreientation landscape. Anyway, I have been trying to play around and use macros so I decided to just write a macro to do it for me. This is a simple macro - all it does is change the print orientation to Landscape.

The green is just information for the user and is not part of the actual macro.
To access the Developer tab where all the macro features exist, in Excel 2010, you need to:
  • Click on File>Options
  • Select Customize Ribbon
  • Select Developer
  • Click OK
Once you have  the Developer tab visible,
  • Copy the code below
  • Click on the Visual Basic icon (or press Alt+F11)
  • Click Insert>Module
  • A blank window will display
  • Click Edit>Paste
  • You can run it to test it or debug it if you wish
  • Click File>Close and Return to Excel
  • Click the Macros icon
  • From there you can edit it, run it, or click on Options to create a shortcut key.
If you record the steps yoursefl, your code will be a lot longer but it will still work. You could also add in whatever other print features you change all the time. I gave mine a shortcut key of Control+Shift+P but you can give it a key combination that makes sense to you.

Sub Landscape_Printing()

' Landscape_Printing Macro
' This macro changes the print setting to landscape.
' Application.PrintCommunication = False
With ActiveSheet.PageSetup
.Orientation = xlLandscape
End With
Application.PrintCommunication = True
End Sub

No comments:

Post a Comment

Ms. Excel- Resident Excel Geek