|
Display the Print Window in Excel
This free Excel macro displays the print window or dialog box in Excel. This is the same window that would appear when you hit Ctrl+P on your keyboard or when you select Print from the file or Office Button menu.
This is a great macro to use when you don't want to give users access to keyboard shortcuts or Excel menus because you can set this macro to a button within the spreadsheet in order to retain print functionality.
Where to install the macro: Module
Excel Macro to Display the Print Window in Excel
Sub Show_Print_Window()
'Shows the print window in Excel - Same thing as hitting Ctrl + P in the keyboard
Application.Dialogs(xlDialogPrint).Show
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
Hi all,
Would anyone be able to tell me how to display a promp at an excel workbook startup so that users agree to the terms and conditions?
Can we create our own Dockable windows (having our own controls) in excel
(Windows 2003) like Getting started, The dockable window that appears when
we click on File -> New.
Please tell me the whether it is possible or not. If so what are the classes
that I need to use and what are the problems that may face if I use the same
code on old versions of excel.
Thanks in advance.
--
Venkat
Hi everyone,
A monthly activity I'm forced to perform is to get a bunch of Excel charts containing key performance indicators and publish them in our Corporate Intranet. Because of their nature, I need to render them uneditable. If I add to that the fact that pdf's load faster than .xls, I elected to convert them to pdf and then link them to the Intranet. An ideal task to perform via a VBA macro, right? I don't have the slightest idea how to do it. Maybe API calls?
If you have any suggestions, I will be much obliged.
Please realize: the linking to the Intranet is not an issue. The conversion of a file to pdf and ability to call up that file afterwards is the problem.
Thanks to you all
Chuck
Hi.
I've been looking all over the internet and I found many people with the same problem but very few suggestions and not a single fix.
Excel is "refusing" to display and print anything on landscape format, it only prints and displays portrait. It did it a few days ago and now it does not work.
The puzzling thing is that it only happens if I use my default printer(Samsung ML 2510) but it does not happen when using an old HP Deskjet 895Cse.
It doesn't seem to be an office problem because it only happens on excel; word and access print fine in my default printer.
I already updated the printer driver, uninstall and installed the whole Office 2003, deleted and add the printer a thousand times, I even tried to plug the printer to the computer instead of having the printer as a networked one, but nothing seems to help.
The printer is networked from my other computer that runs XP Professional. The computer I am having a problem has Vista Premium.
Does anyone have any suggestion ?
Thanks.
When Using VBA Display Window I used to be able to see project explorer and the code in the same screen (Project Explorer on the Left And Code On the Right)
I have lost this split screen I now can only see the code. If I press View Project Explorer in the view menu the code dissapears and the window shows only the project explorer
Please Any Help Would Be Gratefull
If you need to see a screen shot I could send it to you
A few months ago i downloaded a workbook that contained code for a Display Window. By Display Window i mean, in the upper right hand corner of your sheet, there was a window that always displayed a certain range of cells (eg:H3:K17). No matter where you scrolled, these cells were always showing in this small window. I think the sheet came from J-Walk, Pearson or someone like that.
Anybody have this link?
Thx,
Noir
Hi all,
Hope someone can help:
I have a very elaborate Excel workbook that contains several sheets. Each sheet has a print area set and custom page breaks.
I would like to link to the data (not embed it) in a word document. Ideally, the word document would link to several sheets in the excel file, and display the seperate pages defined by the print areas and page breaks as individual pages in word.
Is this even possible? The insert/object/from file in Word is not doing it for me.
Thanks a lot folks!
sd
Hi, I can't for the life of me find the locals window to debug my code. I'm running excel 2004 for mac. There is no 'Locals window' in the View menu, or any other menu for that matter.
Thanks for the help,
Simon
EDIT: this could be clearer. I'm already in the VBA editor, have set breakpoints etc... and am now trying to step through the code to figure out why it doesn't return the value I'm expecting. So what i want to see is the window (called Locals Window on PC) that shows the current values of the variables. -insert hair pulling emoticon here-
Hi All,
Merry Christmas and a Happy New Year to all !!!
I need some help with a very simple macro.
All i need is "click" of the button and the Print Window appears (the one where you can specify the printer, pages etc...
Please help!
Regards,
Nec.
|
|