#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 30
Default Default Printer

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.
  #2   Report Post  
Posted to microsoft.public.excel.misc
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.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 30
Default Default Printer

Where would I place this code to make sure that it's working? Currently, I'm
trying to get the code to see if CheckBox1 = False. If so, then I want the
program to print to the system's default printer.

"Jim Thomlinson" wrote:

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.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
setting the default printer for this workbook only mikecoxffbb Excel Worksheet Functions 1 October 25th 08 01:47 AM
Using non-default printer on start-up Andrew Felsenstein Excel Discussion (Misc queries) 4 November 14th 07 09:23 PM
members on my network printer not able to print to default printer smeheut Excel Discussion (Misc queries) 0 June 18th 07 06:42 PM
Default printer setting John Excel Discussion (Misc queries) 1 March 22nd 07 03:20 PM
Printing from default printer Susan Excel Discussion (Misc queries) 1 February 1st 06 04:23 PM


All times are GMT +1. The time now is 03:05 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"