Hi all
i hope you can help me out with this one.
I want to write all Printers of domain tke.intra to a txt file.
however it keeps giving an error on the description column that comes from the active directory.
When i want to write it in the file it keeps saying
"Typen unverträglich"
This means the type is not string or any kind. I tried to convert it with Cstr but that was a no go...
Any help would be very appreciated!
(you can test this file in you are on a domain, just change the tke and the intra)
Const ADS_SCOPE_SUBTREE = 2
MsgBox "haben Sie bitte 60 Secunden Geduld", VBInformation
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.CommandText = "Select printerName, drivername, ServerName, location, description from " _
& " 'LDAP://DC=tke,DC=intra' where objectClass='printQueue' "
objCommand.Properties("Page Size") = 2000
objCommand.Properties("Timeout") = 30
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.Properties("Cache Results") = False
Set objRecordSet = objCommand.Execute
arrPrinter = objRecordSet.GetRows()
objConnection.Close()
Const ForAppending = 8
Set objFSO = CreateObject("Scripting.FileSystemObject")
CurrTime = Now()
filename = "C:\Printers-" & Left(CurrTime, 10) & ".txt"
Set objTextFile = objFSO.OpenTextFile(filename, ForAppending, True)
MsgBox UBound(arrPrinter,2)
iprinterCount = 0
Description = ""
For intI = 0 to UBound(arrPrinter,2)
Description = (arrPrinter(0,IntI))
strLocation = Trim(arrPrinter(1, IntI))
strServerName = Trim(arrPrinter(2, IntI))
strDrivername = Trim(arrPrinter(3, IntI))
strPrinterName = Trim(arrPrinter(4, IntI))
'objTextFile.WriteLine (strPrinterName & ", " & strServerName & ", " & strDrivername & ", " & strLocation & ", " & Description)
objTextFile.WriteLine (strPrinterName & VBtab & strServerName & VBtab & strDrivername & VBtab & strLocation & VBtab)
objTextFile.Write ( Description)
'objTextFile.WriteLine (strServerName)
Next
MsgBox "fertig"
objTextFile.Close
i hope you can help me out with this one.
I want to write all Printers of domain tke.intra to a txt file.
however it keeps giving an error on the description column that comes from the active directory.
When i want to write it in the file it keeps saying
"Typen unverträglich"
This means the type is not string or any kind. I tried to convert it with Cstr but that was a no go...
Any help would be very appreciated!
(you can test this file in you are on a domain, just change the tke and the intra)
Const ADS_SCOPE_SUBTREE = 2
MsgBox "haben Sie bitte 60 Secunden Geduld", VBInformation
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.CommandText = "Select printerName, drivername, ServerName, location, description from " _
& " 'LDAP://DC=tke,DC=intra' where objectClass='printQueue' "
objCommand.Properties("Page Size") = 2000
objCommand.Properties("Timeout") = 30
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.Properties("Cache Results") = False
Set objRecordSet = objCommand.Execute
arrPrinter = objRecordSet.GetRows()
objConnection.Close()
Const ForAppending = 8
Set objFSO = CreateObject("Scripting.FileSystemObject")
CurrTime = Now()
filename = "C:\Printers-" & Left(CurrTime, 10) & ".txt"
Set objTextFile = objFSO.OpenTextFile(filename, ForAppending, True)
MsgBox UBound(arrPrinter,2)
iprinterCount = 0
Description = ""
For intI = 0 to UBound(arrPrinter,2)
Description = (arrPrinter(0,IntI))
strLocation = Trim(arrPrinter(1, IntI))
strServerName = Trim(arrPrinter(2, IntI))
strDrivername = Trim(arrPrinter(3, IntI))
strPrinterName = Trim(arrPrinter(4, IntI))
'objTextFile.WriteLine (strPrinterName & ", " & strServerName & ", " & strDrivername & ", " & strLocation & ", " & Description)
objTextFile.WriteLine (strPrinterName & VBtab & strServerName & VBtab & strDrivername & VBtab & strLocation & VBtab)
objTextFile.Write ( Description)
'objTextFile.WriteLine (strServerName)
Next
MsgBox "fertig"
objTextFile.Close