View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Mats Samson Mats Samson is offline
external usenet poster
 
Posts: 112
Default Problem with this VBA Code and Network Printers (UNC Path)

Im using another simple solution, by creating a reference to Word and use
the System.PrivateProfileString to read the registry key:

Sub findPDFport ()
Dim WordApp As Word.Application
Dim strSection As String
Dim strAdobePrt As String
Dim pdfPrinter As String
strSection = "HKEY_CURRENT_USER\Software\Microsoft" _
& "\Windows NT\CurrentVersion\Devices"
strAdobePrt = System.PrivateProfileString(Filename:="", _
Section:=strSection, Key:="Adobe PDF")
pdfPrinter = "Adobe PDF on " & Right(strAdobePrt, 5)
MsgBox "The Adobe Printer is on - " & Right(strAdobePrt, 5)
End Sub

with this solution youre able to get the NE-port which seems to change all
the time,
probably when you do some changes to ANY printer setup, its re-indexing.
Theres some additional code if youd like to create a PDF-file from your
printout but I guess you have that already.

Best regards
Mats


"Dick Kusleika" wrote:

On Fri, 11 Apr 2008 14:48:18 +0200, "Holger Hasenmüller"
wrote:


Dim objReg As RegObj.Registry
Dim objRootKey As RegObj.RegKey

in English:
failure at compilation
user defined type is not defined

What's wrong here ?


You need to set a reference to Registration Manipulation Classes (Tools -
References). Or use CreateObject("RegObj.Registry") and dim those variables
as Object.
--
Dick