Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel 2003 loses selection of printer | Setting up and Configuration of Excel | |||
Excel printer selection | Excel Discussion (Misc queries) | |||
Printer Selection | Excel Discussion (Misc queries) | |||
printer selection | Excel Programming | |||
Printer Selection Box | Excel Programming |