Scriptorium

us fr nl




VBA: Printing

Printing pages with a dynamic header or footer
Please check the improved article on my new website here: http://www.vba-and-excel.com/vba/printing/11-printing-pages-with-a-dynamic-header-or-footer In Excel you can set a header or footer to include dynamic data such as the pagenumber or time. However, there is no intrinsic function to add a subtotal for example. This routine shows a method for achieving such. It will calculate the sub total and grand total for a series of numbers and display them in the footer of each page.

Printing from VBA to Dymo Label Printer
There's not much information on the internet on how to print to a Dymo label printer from VBA. This routine shows you how to do it the easy way; using the high level COM interface.

Show Printer Properties Window
Excel can show a number of standard dialogs with the (Application.)Dialogs property. Unfortunately some of the dialogs we use can't be accessed this way, for example a Printer Properties window. This piece of code gets you there using another route.

Printing a form in landscape orientation
You can't set the paper orientation when printing a form because the form doesn't have any suitable properties to set it. However, you can set it for a worksheet so with a little trick we can print a form in landscape. We have to use an API call for that to user32.dll This sub routine creates a new worksheet, copies the form (as a picture) to the new worksheet, set's the paper orientation to landscape and then prints the form(picture). After printing the new worksheet is deleted again. One way to get it done is by using an API call to user32.dll I did a Google search and came up with the code below.

Opening the Printers and Faxmachines menu
One of the things Excel can't do using the (Application.)Dialogs property is open the Printers and Fax machines menu. This code shows you another way to do it using the Shell command.

Print hidden worksheet without showing it
This sub procedure prints a range (A1:C5) on a hidden worksheet (Sheet3) without showing it to the user

Atom Feed
Contact | About This Application | Scriptorium Website