Thread: Default Printer
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Jim Thomlinson Jim Thomlinson is offline
external usenet poster
 
Posts: 5,939
Default Default Printer

The default printer is controlled by the operating system. To get the printer
you need to use an API call something like this...

Private Declare Function GetDefaultPrinter Lib "winspool.drv" Alias
"GetDefaultPrinterA" (ByVal sPrinterName As String, lPrinterNameBufferSize As
Long) As Long

Sub DefaultPrinter()
Dim strDefaultPrinter As String
Dim lngResult As Long
Dim lngLength As Long

strDefaultPrinter = Space(255)
lngLength = 255
lngResult = GetDefaultPrinter(strDefaultPrinter, lngLength)
If lngResult < 0 Then
strDefaultPrinter = Left(strDefaultPrinter, lngLength - 1)
MsgBox strDefaultPrinter
End If

End Sub
--
HTH...

Jim Thomlinson


"aftamath77" wrote:

Is there code that will reference a systems default printer. As of now, i
have code that will print out forms on excel spreadsheets. The problem is,
if a user prints the form to file, a .pdf is created using Adobe. If a user
now wants to print hard copies to the local printer, Excel is still printing
to .pdf. I'm looking for code that will return Excel to printing using hte
systems default printer. I could do this uses the name of the printer on the
computer, but the program will be used in different office areas with
different default printers. So the name of my default printer won't be the
same as another's. Is there a way that Visual Basic can call to a systems's
default printer?

Can anyone help?
Thanks in advance.