Pause Printing in VBA

V

Vijay Chary

:) Hello!!

I have written a Macro in VBA to print Invoices with data
from an Excel Worksheet. But I have about 250 Bills to print. Could someone
tell me how I can include a few more lines of code in my Macro that will
enable pauses in the printing, at a keystroke ?!

I would very much appreciate a solution that is not very
difficult !!

Thank You !!


Vijay
 
J

Jim Cone

I doubt if there is a way to do that.
Maybe you should only print 25 to 50 bills at a time.
Helpful newsgroup posting tips here... http://www.cpearson.com/excel/newposte.htm

--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)




"Vijay Chary"
wrote in message
:) Hello!!
I have written a Macro in VBA to print Invoices with data
from an Excel Worksheet. But I have about 250 Bills to print. Could someone
tell me how I can include a few more lines of code in my Macro that will
enable pauses in the printing, at a keystroke ?!
I would very much appreciate a solution that is not very difficult !!

Thank You !!
Vijay
 
L

Leith Ross

I doubt if there is a way to do that.
Maybe you should only print 25 to 50 bills at a time.
Helpful newsgroup posting tips here...http://www.cpearson.com/excel/newposte.htm

--
Jim Cone
San Francisco, USAhttp://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)

"Vijay Chary"
wrote in message
:) Hello!!
I have written a Macro in VBA to print Invoices with data
from an Excel Worksheet. But I have about 250 Bills to print. Could someone
tell me how I can include a few more lines of code in my Macro that will
enable pauses in the printing, at a keystroke ?!
I would very much appreciate a solution that is not very difficult !!

Thank You !!
Vijay

Hello Vijay,

This macro may help you. You need to be running Excel 2002 or above.

Macro Code
======================================================================================
'Written: March 30, 2008
'Author: Leith Ross
'Summary: Pause a local printer by name
'Note: Windows 2000 and Windows NT 4.0 - This method is not available.

Sub PausePrinter(ByVal Printer_Name As String)

strComputer = "."
Printer_Name = Printer_Name & " on ADMINS" '&
Environ("ComputerName")

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")

Set colPrintJobs = objWMIService.ExecQuery("Select * from
Win32_Printer")

For Each objPrintJob In colPrintJobs
'objPrintJob.Pause - Change this to objPrintJob.Resume to
comntinue
If Printer_Name = objPrintJob.Name Then objPrintJob.Pause
Next objPrintJob

End Sub
=======================================================================================
Sincerely,
Leith Ross
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top