Posted to microsoft.public.excel.programming
|
|
Printers
Thanks chijanzen,
That worked but is there a way to list avalable printers from networked
computers also.
"chijanzen" wrote:
Jason:
try,
Private Declare Sub RtlMoveMemory Lib "Kernel32" (pDest As Long, _
ByVal pSource As Long, ByVal Length As Long)
Private Declare Function lstrlenA Lib "Kernel32" _
(ByVal lpString As Any) As Long
Private Declare Function lstrcpyA Lib "Kernel32" _
(ByVal lpString1 As String, ByVal lpString2 As Long) As Long
Private Declare Function EnumPrintersA Lib "Winspool.drv" _
(ByVal flags As Long, ByVal name As String, ByVal Level As Long, _
pPrinterEnum As Long, ByVal cdBuf As Long, _
pcbNeeded As Long, pcReturned As Long) As Long
Private Sub UserForm_Initialize()
Dim PrinterEnum() As Long, Impr As String
Dim Needed As Long, Returned As Long, I As Integer
Dim Res As Long
EnumPrintersA 2, vbNullString, 2, 0, 0, Needed, 0
If Needed = 0 Then MsgBox "Erreur", vbCritical: Exit Sub
ReDim PrinterEnum(Needed / 4)
If EnumPrintersA(2, vbNullString, 2, PrinterEnum(0), Needed, _
Needed, Returned) = 0 Then MsgBox "Erreur", vbCritical: Exit Sub
For I = 1 To Returned * 21 Step 21
Impr = Space$(lstrlenA(PrinterEnum(I)))
lstrcpyA Impr, PrinterEnum(I)
If PrinterEnum(I + 6) Then _
RtlMoveMemory Res, PrinterEnum(I + 6) + 58, 2
k = k + 1
Me.ComboBox1.AddItem Impr
Next I
End Sub
--
天行健,君*以自強不息
地勢坤,君*以厚德載物
http://www.vba.com.tw/plog/
"Jason Zischke" wrote:
Is there a way for VB Excel to list all the avalable printers on your
computer in a ComboBox.
|