Microsoft Office Tutorials and References
In Depth Information
Example B-2. Calling the GetInstalledPrinters Procedure
Example B-2. Calling the GetInstalledPrinters Procedure
Sub DisplayInstalledPrinters()
Dim sPrinters() As String
Dim cPrinters As Long
Dim i As Integer
Dim msg As String
' Get the installed printers
GetInstalledPrinters sPrinters(), cPrinters
' Create the message and display it
msg = ""
For i = 1 To cPrinters
msg = msg & sPrinters(i) & vbCrLf
Next i
MsgBox msg, , cPrinters & " Printers"
End Sub
The output of this macro on my system is shown in Figure B-1 .
Figure B-1. Installed printers
One word of caution: before executing the GetInstalledPrinters subroutine for the first
time (through the DisplayInstalledPrinters macro or any by other means), be sure to save
all of your work in all of your open applications. If you have made an error in typing in this
program, the result may be a system-wide computer crash, in which case you will loose all
unsaved work
Search JabSto ::

Custom Search