+ Reply to Thread
Results 1 to 4 of 4

Detect printer properties

  1. #1
    Jos Vens
    Guest

    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



  2. #2
    Forum Contributor
    Join Date
    12-11-2004
    MS-Off Ver
    2007
    Posts
    137
    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

  3. #3
    Tom Ogilvy
    Guest

    Re: 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" <jos.vens@pro.tiscali.be> wrote in message
    news:OWSpGEkMGHA.1536@TK2MSFTNGP11.phx.gbl...
    > 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
    >
    >




  4. #4
    keepITcool
    Guest

    Re: 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@excelforum-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")


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1