NessPJ
Active Member
- Joined
- May 10, 2011
- Messages
- 431
- Office Version
- 365
Hello all,
After an upgrade to Office 2016 and Windows 10 on several computers i noticed that the code i use to determine the printerport in my VBA routine no longer works.
Does anyone know how to fix this?
I tried changing the regkey location to "Software\Microsoft\Windows NT\CurrentVersion\Devices" because i read about that somewhere, but i'm guessing that just holds the device lists rather than the printer ports.
After an upgrade to Office 2016 and Windows 10 on several computers i noticed that the code i use to determine the printerport in my VBA routine no longer works.
Does anyone know how to fix this?
Code:
Public Function GetPrinterPort(strPrinterName As String) As String
Dim objReg As Object, strRegVal As String, strValue As String
Const HKEY_CURRENT_USER = &H80000001
Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
strRegVal = "Software\Microsoft\Windows NT\CurrentVersion\PrinterPorts"
objReg.getstringvalue HKEY_CURRENT_USER, strRegVal, strPrinterName, strValue
GetPrinterPort = Split(strValue, ",")(1)
End Function
I tried changing the regkey location to "Software\Microsoft\Windows NT\CurrentVersion\Devices" because i read about that somewhere, but i'm guessing that just holds the device lists rather than the printer ports.
Last edited: