Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Problem with this VBA Code and Network Printers (UNC Path)
Hallo NG,
if work with the Code 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_CURREN T_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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Path to a network drive | Excel Discussion (Misc queries) | |||
Dir Path Code Problem | Excel Programming | |||
Network printers, how? | Excel Programming | |||
Saving to a Network Path using VBA | Excel Programming | |||
Network Path | Excel Programming |