![]() |
Detect printer properties
Hi,
I wonder if it is possible to detect all printer properties in a loop? Like I know the command activesheet.PageSetup.BlackAndWhite = true where can I find all properties like BlackAndWhite? We have a particular Printer/Copier in which we can put a usercode, so any user can be billed for his code. I would like to set the code in the textbox of the printerdefinition by VBA in stead of letting the user do it. The textbox in the printer definition is called Vallid Access of the Nashuatec DSC424.. Can anyone help? I think if I can print a list of properties, it will be obvious which property I have to manipulate. Code should look like For each vProperty in myPrinter.properities debug.print vProperty.name next Thanks! Jos Vens |
Detect printer properties
Hello if WindowsXP is installed you may use Sub proprietesImprimantes() ' 'http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_printerconfiguration.asp ' Dim objWMIService As Object, colItems As Object Dim objItem As Object Dim strComputer As String Dim i As Byte On Error Resume Next strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * from Win32_PrinterConfiguration", , 48) For Each objItem In colItems i = i + 1 Cells(1, i) = "BitsPerPel: " & objItem.BitsPerPel Cells(2, i) = "Caption: " & objItem.Caption Cells(3, i) = "Collate: " & objItem.Collate Cells(4, i) = "Color: " & objItem.Color Cells(5, i) = "Copies: " & objItem.Copies Cells(6, i) = "Description: " & objItem.Description Cells(7, i) = "DeviceName: " & objItem.DeviceName Cells(8, i) = "DisplayFlags: " & objItem.DisplayFlags Cells(9, i) = "DisplayFrequency: " & objItem.DisplayFrequency Cells(10, i) = "DitherType: " & objItem.DitherType Cells(11, i) = "DriverVersion: " & objItem.DriverVersion Cells(12, i) = "Duplex: " & objItem.Duplex Cells(13, i) = "FormName: " & objItem.FormName Cells(14, i) = "HorizontalResolution: " & objItem.HorizontalResolution Cells(15, i) = "ICMIntent: " & objItem.ICMIntent Cells(16, i) = "ICMMethod: " & objItem.ICMMethod Cells(17, i) = "LogPixels: " & objItem.LogPixels Cells(18, i) = "MediaType: " & objItem.MediaType Cells(19, i) = "Name: " & objItem.Name Cells(20, i) = "Orientation: " & objItem.Orientation Cells(21, i) = "PaperLength: " & objItem.PaperLength Cells(22, i) = "PaperSize: " & objItem.PaperSize Cells(23, i) = "PaperWidth: " & objItem.PaperWidth Cells(24, i) = "PelsHeight: " & objItem.PelsHeight Cells(25, i) = "PelsWidth: " & objItem.PelsWidth Cells(26, i) = "PrintQuality: " & objItem.PrintQuality Cells(27, i) = "Scale: " & objItem.Scale Cells(28, i) = "SettingID: " & objItem.SettingID Cells(29, i) = "SpecificationVersion: " & objItem.SpecificationVersion Cells(30, i) = "TTOption: " & objItem.TTOption Cells(31, i) = "VerticalResolution: " & objItem.VerticalResolution Cells(32, i) = "XResolution: " & objItem.XResolution Cells(33, i) = "YResolution: " & objItem.YResolution Columns(i).AutoFit Next End Sub regards michel -- michelxld ------------------------------------------------------------------------ michelxld's Profile: http://www.excelforum.com/member.php...o&userid=17367 View this thread: http://www.excelforum.com/showthread...hreadid=512707 |
Detect printer properties
Only a select set of properties are supported by VBA/Excel. You would
probably need to query the manufacture for how you might set this code using code and would probably have to use the windows API to do it if it was supported at all. You can see what is supported by turning on the macro recorder and changing one of the properties manually - then turn off the macro recorder and see what properties are listed. -- Regards, Tom Ogilvy "Jos Vens" wrote in message ... Hi, I wonder if it is possible to detect all printer properties in a loop? Like I know the command activesheet.PageSetup.BlackAndWhite = true where can I find all properties like BlackAndWhite? We have a particular Printer/Copier in which we can put a usercode, so any user can be billed for his code. I would like to set the code in the textbox of the printerdefinition by VBA in stead of letting the user do it. The textbox in the printer definition is called Vallid Access of the Nashuatec DSC424.. Can anyone help? I think if I can print a list of properties, it will be obvious which property I have to manipulate. Code should look like For each vProperty in myPrinter.properities debug.print vProperty.name next Thanks! Jos Vens |
Detect printer properties
Hi Jos,
WMI can be used to retrieve the printerconfiguration properties BUT you cannot manipulate them using WMI as they are readonly. However the code below lists only the standard props. Go into the immediate pane in VBE and mine all 86 properties of the Win32_Printer WMI object. You'll need API programming to set them with code. Certainly if it concerns some special manufacturers properties, this aint going to be easy. If you find the proper property's ID with the WMI script let me know. Maybe I can help. -- keepITcool | www.XLsupport.com | keepITcool chello nl | amsterdam michelxld wrote in <news:<michelxld.23a251_1140018302.9229@excelfor um-nospam.com Hello if WindowsXP is installed you may use Sub proprietesImprimantes() ' 'http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmis dk/wmi/win32_printerconfiguration.asp ' Dim objWMIService As Object, colItems As Object Dim objItem As Object Dim strComputer As String Dim i As Byte On Error Resume Next strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") |
All times are GMT +1. The time now is 09:55 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com