Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Printer Selection

Greetings Time Travelers. . . Sorry wrong group. And now for something
completely on topic.

I have an Excel app that must print to an impact printer. This printer is
not the default printer. I would like to have Excel do the work in selecting
this specific printer when the app runs. Of course it should return the
previously selected default printer as such.

For this to work effortlessly, a check for a specific printer would need to
be made. If it does not exist print nothing and exit. This is not a networked
printer (yet) and can not be easily selected if it is not already installed.

Your help in developing code to check for and select a specific printer is
greatly appreciated.

Hal
Detroit, MI

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Printer Selection

http://support.microsoft.com/?ID=166008
ACC: Enumerating Local and Network Printers

Enumerating Windows' Available Ports
http://www.mvps.org/vbnet/code/enums/enumports.htm
=======================

Posting by KeepItcool

Option Explicit

Private Declare Function GetProfileString Lib "kernel32" _
Alias "GetProfileStringA" _
(ByVal lpAppName As String, ByVal lpKeyName As String, _
ByVal lpDefault As String, ByVal lpReturnedString As String, _
ByVal nSize As Long) As Long

Sub showlist()
MsgBox Join(PrinterList, vbNewLine)
End Sub


Function PrinterList()
Dim lRet As Long
Dim sBuffer As String
Dim lSize As Long
Dim avTmp As Variant
Dim aPrn() As String
Dim n%, sPrn$, sConn$, sPort$

'Get localized Connection string
avTmp = Split(Excel.ActivePrinter)
sConn = " " & avTmp(UBound(avTmp) - 1) & " "
'Get Printers
lSize = 1024
sBuffer = Space(lSize)
lRet = GetProfileString("devices", vbNullString, vbNullString, _
sBuffer, lSize)
sBuffer = Left(sBuffer, lRet)
avTmp = Split(sBuffer, Chr(0))

ReDim Preserve avTmp(UBound(avTmp) - 1)
For n = 0 To UBound(avTmp)
lSize = 128
sBuffer = Space(lSize)
lRet = GetProfileString("devices", avTmp(n), vbNullString, _
sBuffer, lSize)
sPort = Mid(sBuffer, InStr(sBuffer, ",") + 1, _
lRet - InStr(sBuffer, ","))
avTmp(n) = avTmp(n) & sConn & sPort
Next
PrinterList = avTmp
End Function


--
Regards,
Tom Ogilvy

"Hal" wrote in message
...
Greetings Time Travelers. . . Sorry wrong group. And now for something
completely on topic.

I have an Excel app that must print to an impact printer. This printer is
not the default printer. I would like to have Excel do the work in

selecting
this specific printer when the app runs. Of course it should return the
previously selected default printer as such.

For this to work effortlessly, a check for a specific printer would need

to
be made. If it does not exist print nothing and exit. This is not a

networked
printer (yet) and can not be easily selected if it is not already

installed.

Your help in developing code to check for and select a specific printer is
greatly appreciated.

Hal
Detroit, MI



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
Excel 2003 loses selection of printer Shirlo Setting up and Configuration of Excel 0 May 4th 07 05:42 PM
Excel printer selection dave1816 Excel Discussion (Misc queries) 2 April 2nd 07 11:34 PM
Printer Selection Frank R Excel Discussion (Misc queries) 2 May 20th 05 04:31 PM
printer selection Craig Wilks[_2_] Excel Programming 1 October 1st 04 01:44 PM
Printer Selection Box Susan Lund Excel Programming 3 August 24th 04 06:41 PM


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

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

About Us

"It's about Microsoft Excel"