HELP: how to detect if printers are installed? woes :S

  • Thread starter Thread starter KevinGPO
  • Start date Start date
K

KevinGPO

I made a Excel template with a macro to set up page margins, etc for the
printer. This macro is ran when you load up the Excel template.

However, if once doesn't have any printers installed, they get a warning to
chose/find/setup a printer.

Does anyone know in VBA how to detect whether any printers are installed. If
no printer is installed then bypass my printer setup code?
 
Hi
An error message is generated when you try and print with no printer.
I Googled this group and found this code from Tom Ogilvy which you
might be able to adapt. I don't know how you catch the error without
trying the print though - maybe some kind of test print when the user
first tries to use your code, which then gives a warning if no print
possible?

Sub PrintInvoice()
Dim Res As Long
Res = MsgBox("Do you want to print the invoice?", vbQuestion +
vbYesNo)
Select Case Res
Case vbYes
On Error Resume Next
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
if err.Number <> 0 then _
MsgBox "Error: " & err.Description, vbOK +
vbInformation
Err.clear
On Error goto 0
Case vbNo
Exit Sub
End Select
End Sub

regards
Paul
 

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

Back
Top