|
Print Preview Screen Display for The Current or Selected Worksheets in Excel
This free Excel macro allows you to display the print preview screen or window for the current or selected worksheets in Excel. If you do not select more than one worksheet, only the active worksheet will be viewed in the print preview mode. If multiple worksheets are chosen, multiple worksheets will be displayed in print preview mode.
This is a great macro because from the print preview screen you can access all of the page setup features as well as directly printing from this screen.
Where to install the macro: Module
Macro to Display The Print Preview Screen for The Current or Selected Worksheets in Excel
Sub Print_Preview_Current_Worksheet()
'Show the print preview window for the selected worksheet in Excel
ActiveWindow.SelectedSheets.PrintPreview
End Sub
How to Install the Macro
- Select and copy the text from within the grey box above.
- Open the Microsoft Excel file in which you would like the Macro to function.
- Press "Alt + F11" - This will open the Visual Basic Editor - Works for all Excel Versions.
Or For other ways to get there, Click Here.
For Excel Versions Prior to Excel 2007 Go to Tools > Macros > Visual Basic Editor
For Excel 2007 Go to Office Button > Excel Options > Popular > Click Show Developer tab in the Ribbon. Then go to the Developer tab on the ribbon menu and on the far left Click Visual Basic
- On the new window that opens up, go to the left side where the vertical pane is located. Locate your Excel file; it will be called VBAProject (YOUR FILE'S NAME HERE) and click this.
- If the Macro goes in a Module, Click Here, otherwise continue to Step 8.
- Go to the menu at the top of the window and click Insert > Module
- Another window should have opened within the Visual Basic Editor's window. Within this new window, paste the macro code. Make sure to paste the code underneath the last line of anything else that is in the window.
- Go to Step 8.
- If the Macro goes in the Workbook or ThisWorkbook, Click Here, otherwise continue to Step 8.
- Directly underneath your excel file called VBAProject(your file's name here), click the Microsoft Excel Objects folder icon to open that drop-down list.
- Then, at the bottom of the list that appears, double-click the ThisWorkbook text.
- A new window inside the Visual Basic Editor's window will appear. In this new window, paste the code for the macro. Make sure to paste this code underneath the last line of any other code which is already in the window.
- Go to Step 8.
- If the Macro goes in the Worksheet Code, Click Here, otherwise continue to Step 8.
- Directly underneath your excel file called VBAProject(your file's name here), click the Microsoft Excel Objects folder icon to open that drop-down list.
- Within the list that appears you will see every worksheet that is in that excel file. They will be listed as such: Sheet1(NAME OF SHEET HERE) and under that will be Sheet2(NAME OF SHEET HERE). Select the sheet in which you want the macro to run and double-click that sheet.
- A new window inside the Visual Basic Editor's window will appear. In this new window, paste the code for the macro. Make sure to paste this code underneath the last line of any other code which is already in the window.
- Repeat steps b and c for every sheet you want the macro to work in. Putting the macro in one sheet will not enable it for any other sheets in the workbook.
- Go to Step 8.
- Close the Microsoft Visual Basic Editor window and save the Excel file. When you close the Visual Basic Editor window, the regular Excel window will not close.
- You are now ready to run the macro.
Similar Helpful Excel Resources
Using Office 2007, but it worked in Office 2003. Win XP, Office 2007 Excel. I am updating my phone book, 1 column 75.0 wide, Text. Type in a name & address and space over to the right and enter the phone number. Space n number of times so as to align the numbers. Using Arial TT font, the screen alignment of the phone number does not match Print Preview alignment. Printing matches Print Preview. Using a second column for the number is not an option. Courier font is not an option. Use a table in MS Word is a solution because it works there, but does not fix the Excel problem.
I'm developing an application in Excel 2007 and open the workbook in Full Screen mode.
I have 2 questions:
Can I stop the user exiting full screen mode? Obviously I will need to make this ability available to myself so that I can modify, but I wonder if there's a way I can password protect this?
I have a button on the main page for printing a report. This runs a macro which hides some sheets and prints the remaining sheets:
ActiveWorkbook.PrintOut Copies:=1, Preview:=True
However, in full screen mode, the user doesn't see the close preview or print options so they can preview the report but have to exit full screen mode to actually print it! Not ideal. Does anyone know how I can get round this, particularly bearing in mind my first question?
Any thoughts would be appreciated. Thanks
Help!!!!
Several members of my faculty are experiancing difficulty with a sheet in a workbook that they use not printing properly.
Specificly, the text contents in the cells of this particular column appear to fit each cell on screen, text is all single spaced on screen and is word wrapping properly.
When my faculty go to print this worksheet, the text in the aforementioned cells Appear to be double spaced and not all of the text appears. (The cells are physicly the same width as on screen/print preview... its almost like the cell contents expanded to double spaceing and are hidden behind the cells below it).
One of my faculty members emailed this worksheet to someone outside of our building and that person was able to sucessfuly print the worksheet without the doublespaceing issue.
It should be noted that other faculty memebers have not had any problems, only a small select few.
The printers we use in house are HP 4500, and HP 2100 (both are laser printers).
Any advice in this matter would be greatly appreciated.
- Zoebear
Microsoft Excel 2003
When in the print preview pane i am unable to adjust the bottom margin. It
is invisible, however when you hover over top of where it is you're able to
drag it. The result is that it goes back to where it was at .55 and
invisible. Left, right and center are visible and work fine. Attempted
View-options and manually typed in .2 instead of .55 to no avail. It's the
FOOTER MARGIN that's the problem! Got a fix?
Please let me know
Thanks
My workbook has several rows at the top which I want to use as a header for the first few pages, but not the last. So I've used some VBA code in the beforeprint event to cancel the print job, print the first few pages of the workbook, hide the unwanted rows and then print the last page.
It worked fine in Excel 2003 but in Excel 2007 the print preview command bar is not displayed so the user has no way of closing the print preview except closing the application from the taskbar.
Is there a way of displaying the print preview commandbar in Excel 2007?
Hi There,
Am wanting to write some code that displays a sheet in print preview, waits for 10 seconds, then moves onto another sheet but seems that whenever print preview is on, the macro stops running until the preview is manually closed.
Any thoughts?
Cheers - Paul
Hi, I am trying to determine the users screen resolution because the size of
charts etc, are going to be dependant on this. I have some code but for
some reason it returns 800x600 on my monitor when it should be 1280x1024.
Can anyone shed any light on this one?
Here is the code:
Sub screensize()
Dim strSize As String
With Application.DefaultWebOptions
Select Case .screensize
Case msoScreenSize800x600
strSize = "800x600"
Case msoScreenSize1024x768
strSize = "1024x768"
Case msoScreenSize1280x1024
strSize = "1280x1024"
Case Else
strSize = "1280x1024"
End Select
End With
MsgBox strSize
End Sub
(See Attached Screenshot)
When one is in the Main Menu (screen is not maximized) of the timesheets for a fiscal year, there are magnifying glasses that allow one to view the "Print Preview" screen for each pay cycle. Right now, when one clicks on a magnifying glass, it shows the respective "Print Preview" screen shrunk to fit the non-maximized screen. Is there a way to make it automatically show the full screen version of the "Print Preview" upon clicking on the magnifying glass?
I have changed what I am doing with this, rendering the question moot. Thanks anyway :-)
|
|