ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   HELP: how to detect if printers are installed? woes :S (https://www.excelbanter.com/excel-worksheet-functions/77132-help-how-detect-if-printers-installed-woes-s.html)

KevinGPO

HELP: how to detect if printers are installed? woes :S
 
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?



[email protected]

HELP: how to detect if printers are installed? woes :S
 
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

KevinGPO wrote:
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?




All times are GMT +1. The time now is 04:26 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com