H
Holger Hasenmüller
Hallo NG,
if i work with the Code (i know it is for Excel ;-) below (from
http://www.xlam.ch/vbacode/index.htm), i have the problem, that it only
works with local printers.
But if i connect my networkprinters with the microsoft tool "con2prt", the
printername is for example: \\printservername\ADOBE-PDF
When i write Const strPrinter As String = "\\printservername\ADOBE-PDF" i
get the failure:
"Printer '\\printservername\ADOBE-PDF' - The Port Name was not found"
What is the problem with networkprinters ??
Kind regards
Hassan
Sub GetPrinterPortName()
Const strPrinter As String = "HP LaserJet 4M Plus"
Dim strSetting As String
Dim strPort As String
Dim intChar As Integer
On Error Resume Next
strSetting =
CreateObject("WScript.Shell").RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows
NT\CurrentVersion\Devices\" & strPrinter)
If Err.Number = -2147024894 Then
MsgBox "Es existiert kein Drucker '" & strPrinter & "'.", vbInformation
Exit Sub
End If
For intChar = Len(strSetting) To 1 Step -1
If Mid$(strSetting, intChar, 1) = "," Then
strPort = Mid$(strSetting, intChar + 1)
Exit For
End If
Next intChar
If strPort = "" Then
MsgBox "Drucker '" & strPrinter & "'" & vbCrLf & vbCrLf & _
"Der Port-Name wurde nicht gefunden!", vbExclamation
Else
MsgBox "Drucker '" & strPrinter & "'" & vbCrLf & vbCrLf & "Name des
Ports: " & strPort & vbCrLf & _
"Excel-Druckerbezeichnung: " & strPrinter & " auf " & strPort,
vbInformation
End If
End Sub
if i work with the Code (i know it is for Excel ;-) below (from
http://www.xlam.ch/vbacode/index.htm), i have the problem, that it only
works with local printers.
But if i connect my networkprinters with the microsoft tool "con2prt", the
printername is for example: \\printservername\ADOBE-PDF
When i write Const strPrinter As String = "\\printservername\ADOBE-PDF" i
get the failure:
"Printer '\\printservername\ADOBE-PDF' - The Port Name was not found"
What is the problem with networkprinters ??
Kind regards
Hassan
Sub GetPrinterPortName()
Const strPrinter As String = "HP LaserJet 4M Plus"
Dim strSetting As String
Dim strPort As String
Dim intChar As Integer
On Error Resume Next
strSetting =
CreateObject("WScript.Shell").RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows
NT\CurrentVersion\Devices\" & strPrinter)
If Err.Number = -2147024894 Then
MsgBox "Es existiert kein Drucker '" & strPrinter & "'.", vbInformation
Exit Sub
End If
For intChar = Len(strSetting) To 1 Step -1
If Mid$(strSetting, intChar, 1) = "," Then
strPort = Mid$(strSetting, intChar + 1)
Exit For
End If
Next intChar
If strPort = "" Then
MsgBox "Drucker '" & strPrinter & "'" & vbCrLf & vbCrLf & _
"Der Port-Name wurde nicht gefunden!", vbExclamation
Else
MsgBox "Drucker '" & strPrinter & "'" & vbCrLf & vbCrLf & "Name des
Ports: " & strPort & vbCrLf & _
"Excel-Druckerbezeichnung: " & strPrinter & " auf " & strPort,
vbInformation
End If
End Sub