View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
urkec urkec is offline
external usenet poster
 
Posts: 131
Default Check available pagesize

I think you can use this:



Sub PrinterPaperSizes()

Computer = "."
Set WMISrv = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& Computer & "\root\cimv2")

Set Printers = WMISrv.ExecQuery _
("Select * from Win32_Printer ")

For Each Printer In Printers
For Each pn In Printer.PrinterPaperNames
Debug.Print Printer.Name & " supports " & pn
Next
Next

End Sub


It should return available paper sizes for all printers .

If you want the information just for one printer you need to specify the
printer name:

Set Printers = WMISrv.ExecQuery _
("Select * from Win32_Printer " & _
"Where Name = 'HP LJet 1020'")

You could use Printer.PaperSizesSupported instead of
Printer.PrinterPaperNames, but then you would have to map paper sizes to ints
( A2 = 20 ...)

For Each ps In Printer.PaperSizesSupported
Debug.Print Printer.Name & " supports " & ps
Next


Hope this helps some.

--
urkec


"GerardV" wrote:

Is it possible to check if a printer (on the network) can handle a certain
page size, for instants A2 size???
I've solved it for now by error handling during setting of page size, by
asking to select an other printer. Problem is that when a second printer is
chosen that also doesn't support A2 paper size the macro stops on error......

Suggestions anyone???



--
-----------------------------