Changing Printers (was Re: Getz code error/setting printer info) 
Author Message
 Changing Printers (was Re: Getz code error/setting printer info)

Thanks everybody for your responses.  I will be sure to get the how-to book,
and see if I can get an upgrade to 97.  In the mean time, is the information
in the book regarding glr_APIGetDeviceString accurate for Windows NT?

Function GetPrinterInfo(strPrinterStr As String) As String
    Dim intCount As Integer
    intCount = glr_apiGetProfileString("Windows", "Device", "Device",
                strPrinterStr, 254)
    GetPrinterInfo = strPrinterStr
End Function

This code is a bit ambiguous.  What I want is to retrieve the device string
for strPrinterStr so that I can parse it and fill in a glr_tagDeviceRec with
the printer name, driver and port.  This code will return whatever the current
printer string is regardless of what is passed (as long as the passed string
is as long or longer than the printer's string).

Could somebody please point out what I am doing wrong here?  I think I have
most everything else in place in order to change printers.

Thanks,

Edward R. Smith
Tri-Tech Electronics, Inc.
Orlando, FL



Sun, 02 Apr 2000 03:00:00 GMT  
 Changing Printers (was Re: Getz code error/setting printer info)



Quote:
> This code is a bit ambiguous.  What I want is to retrieve the device string
> for strPrinterStr so that I can parse it and fill in a glr_tagDeviceRec with
> the printer name, driver and port.  This code will return whatever the current
> printer string is regardless of what is passed (as long as the passed string
> is as long or longer than the printer's string).

Ambiguous? Nothing ambiguous about it. Just not quite complete.  If that
code's from the book, it's WRONG. Look for the examples in the book that
call GetProfileString, and you'll see that you must trim off excess junk
from the function call. as in

  GetPrinterInfo = Left(strPrinterStr, intCount)

Again, if you got that procedure from the book, please let me know.  It's
just wrong. If it's not, I'm not quite sure why you're rewriting this
code -- everything you need to do is already taken care of for you in the
book. You should only need to call a top-level routine (I don't remember
which one) that will take care of ALL the details for you.  I believe
you're making it more difficult than you need to. -- Ken



Mon, 03 Apr 2000 03:00:00 GMT  
 Changing Printers (was Re: Getz code error/setting printer info)

Quote:

>Again, if you got that procedure from the book, please let me know.  It's
>just wrong. If it's not, I'm not quite sure why you're rewriting this

It is written at the beginning of Chapter 10: Controlling your printer.  It is
not actually called in the code, so far as I can tell.  The code uses
glr_apiGetSection  instead.

Quote:
>code -- everything you need to do is already taken care of for you in the
>book. You should only need to call a top-level routine (I don't remember
>which one) that will take care of ALL the details for you.  I believe
>you're making it more difficult than you need to. -- Ken

What I want is to either set my reports' prtdevnames and prtdevmode permanatly
or else reset them to FAX when they open.  I believe that your code resets
those properties to their old values.  Also, it always references the form.  I
think that I have gotten what I need though.  It looks something like this

    glrGetDevices adevlist() 'adevlist() is of type glr_tagDeviceRec
    For intK = 0 To UBound(adevlist)
        If adevlist(intK).strdevicename = strPrinterName Then
            dr = adevlist(intK)
        End If
    Next

    varnewdevname = glrBuildDevNames(dr)

This is working, but Access was complaining about passing the array.  I
thought it was because I had dimmed it in another module that it was being
called from, anyway I started to make a new module to combine all of the subs
I needed and now Access is calling Dr. Watson whenever I try to save a module.
I figure this is that Access95-being-a-transition-product problem that I have
been told about.

Thanks for your input Ken,

Edward R. Smith
Tri-Tech Electronics, Inc.
Orlando, FL



Mon, 03 Apr 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Getz code error/setting printer info

2. Problem setting the active printer of Word 97 without changing the Windows default printer

3. Changing the printer capture and setting printer driver

4. How to change the printer driver for a defined printer in VB code

5. Changing Printers property reset printer to Windows default printer

6. setting/changing default printer via code (VBA)

7. Printer Dialog sets System Wide Printer settings....

8. Printer Dialog sets System Wide Printer settings....

9. Setzen Papierformaten am Drucker / Setting of Paperformats on Printer

10. Setzen Papierformaten am Drucker / Setting of Paperformats on Printer

11. Setzen Papierformaten am Drucker / Setting of Paperformats on Printer

12. Get and set printer properties info from Word using VBA

 

 
Powered by phpBB® Forum Software