LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Path to a network drive CWillis Excel Discussion (Misc queries) 2 June 23rd 06 03:06 AM
Dir Path Code Problem Todd Huttenstine Excel Programming 2 April 1st 04 11:27 PM
Network printers, how? CAA[_16_] Excel Programming 2 February 5th 04 05:09 PM
Saving to a Network Path using VBA Mike R Excel Programming 1 August 11th 03 10:34 AM
Network Path Karen[_5_] Excel Programming 2 August 5th 03 12:05 PM


All times are GMT +1. The time now is 12:33 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"