M
mikeolson
I found this code that when you CTRL+G from Visual Basic it displays all my
printers:
Sub PrinterSelect_macro()
Dim wshNetwork As Object
Dim oDrives As Object
Dim oPrinters As Object
Dim iCount As Integer
Dim sCurrentprinter As String
sCurrentprinter = Application.ActivePrinter
Set wshNetwork = CreateObject("WScript.Network")
Set oDrives = wshNetwork.EnumNetworkDrives
Set oPrinters = wshNetwork.EnumPrinterConnections
For iCount = 0 To oPrinters.Count - 1 Step 2
Debug.Print "Printer Port " & oPrinters.Item(iCount) _
& " = " & oPrinters.Item(iCount + 1)
Next
Range("AI35") = sCurrentprinter 'I added this line and it pastes my HP
DeskJet in cell AI35
End Sub
I added the line where it pastes the printer name in AI35 (same sheet as
code). What I want it to do is, paste the next printer in AI36, then the
following in AI37 and so on. When I CTRL+G and run macro it shows 5
printers, I would like to allow for around 20 (AI35:AI54). I tried several
ways to loop it and move down to the next cell but I cannot get it to work.
So if I had 10 printers (network included) it would have all 10 listed from
cells AI35:AI44. Thank you for your help!
Mike Olson
printers:
Sub PrinterSelect_macro()
Dim wshNetwork As Object
Dim oDrives As Object
Dim oPrinters As Object
Dim iCount As Integer
Dim sCurrentprinter As String
sCurrentprinter = Application.ActivePrinter
Set wshNetwork = CreateObject("WScript.Network")
Set oDrives = wshNetwork.EnumNetworkDrives
Set oPrinters = wshNetwork.EnumPrinterConnections
For iCount = 0 To oPrinters.Count - 1 Step 2
Debug.Print "Printer Port " & oPrinters.Item(iCount) _
& " = " & oPrinters.Item(iCount + 1)
Next
Range("AI35") = sCurrentprinter 'I added this line and it pastes my HP
DeskJet in cell AI35
End Sub
I added the line where it pastes the printer name in AI35 (same sheet as
code). What I want it to do is, paste the next printer in AI36, then the
following in AI37 and so on. When I CTRL+G and run macro it shows 5
printers, I would like to allow for around 20 (AI35:AI54). I tried several
ways to loop it and move down to the next cell but I cannot get it to work.
So if I had 10 printers (network included) it would have all 10 listed from
cells AI35:AI44. Thank you for your help!
Mike Olson