Results 1 to 5 of 5
  1. #1
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    DevMode DeviceName (VBA 6/OXP)

    Does anyone know a way to retrieve/use a printer device name longer than 32 characters using PrinterOpen API calls and DEVMODE? We have a user who managed to get a printer with a device name longer than 32 characters and our app won't recognize the printer and so won't print to it. Unfortunately, it isn't a simple matter of changing the devicename element to higher than 32. When we do that, some reports no longer switch paper sizes. Instead, they stay locked on legal size paper.
    Charlotte

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: DevMode DeviceName (VBA 6/OXP)

    Does this newsgroup post help? It suggests using DevNames instead of DevMode.

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: DevMode DeviceName (VBA 6/OXP)

    It doesn't look too much different from what we're using, but I'm going to study it further tomorrow. I'm also going to try and find out if the problem revolves around an NT machine, which hadn't occured to me. Thanks, Hans.
    Charlotte

  4. #4
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: DevMode DeviceName (VBA 6/OXP)

    Charlotte,

    If you can use the Windows Script Host (WSH), you can access the EnumPrinterConnections method of the Wscript.Network object. The method returns a list of pairs of items relating to each connected printer, both local and network. The first item of the pair gives the Port and the second the printer Name (sharename in the case of network printers).

    The following example should illustrate :

    Sub ListPrinters()
    Dim oWsh, oPrinters
    Set oWsh = CreateObject("Wscript.Network")
    Set oPrinters = oWsh.EnumPrinterConnections
    For i = 0 To oPrinters.Length - 2 Step 2
    Debug.Print "Port : ", oPrinters.Item(i), _
    "Name : ", oPrinters.Item(i + 1)
    Next
    Set oPrinters = Nothing
    Set oWsh = Nothing
    End Sub


    I'm not sure if it suits your circumstances, but maybe worth a try.

    Andrew

  5. #5
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: SOLVED - DevMode DeviceName (VBA 6/OXP)

    Thanks, but I'm mucking around in the API calls and anything we build has to work everywhere, regardless of whether the WSH is available. We actually modify the DevMode for reports on the fly, and I found that changing one constant in my module to set the maximum device to greater than 32 allowed me to handle long printer names. I suspect the original code was for Win 98 and below, since they didn't allow long printer names the way NT and above do. I guess we'll find out if a stray installation of Win98 turns up somewhere <img src=/S/crossfingers.gif border=0 alt=crossfingers width=17 height=16>, although the application is designed to run on a server or at least a powerful workstation, so that isn't likely.
    Charlotte

Posting Permissions

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