ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Managing Printing (https://www.excelbanter.com/excel-programming/369782-managing-printing.html)

darusman[_2_]

Managing Printing
 

Hi,

I dont know the question which i am going to ask you all is a possibl
or not. I am actually new to VBA and Macros in excel, so any help woul
be appreciated.
Problem:
I have multiple network printers installed on my computer, one of the
is my default. What I want to do is I want a macro which runs everytim
when I want to print something and asks me which printer you want to us
for these prints, it should ask me from the list of printers installe
on my PC. Please try to simplify things because sorry to say i am ne
to This.

Thanks Very Much

--
darusma
-----------------------------------------------------------------------
darusman's Profile: http://www.excelforum.com/member.php...fo&userid=3691
View this thread: http://www.excelforum.com/showthread.php?threadid=56961


Simon Lloyd[_854_]

Managing Printing
 

This was posted a little while ago by Tom Ogilvy, i suggest you check
out the links first before attempting to use the code for selecting a
printer!

Regards,
Simon

Tom Ogilvy Posts: n/a

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


--
Simon Lloyd
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.excelforum.com/member.php...fo&userid=6708
View this thread: http://www.excelforum.com/showthread...hreadid=569612



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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com