Results 1 to 10 of 10
  1. #1
    5 Star Lounger
    Join Date
    Feb 2001
    Location
    Youngstown, Ohio, USA
    Posts
    705
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Change printer for PrintOut (A2K SR1)

    Is there any way to tell Access to use a non-default printer when printing a report via the PrintOut macro command? I had been running a database on my computer, printing to a nice fast laser printer. Now the database has been moved to a computer that uses a slow inkjet printer as its default. Reports that took 10-15 minutes to print now take 1 - 1 1/2 hours to print. The pc in question is connected to faster networked printers, but before now it was mostly used for sporadic light-duty printing, and changing the default printer is not a viable solution at this time.

    I havn't seen any macro command that could either redirect to a non-default printer, or even to change the default printer (to be restored at the end of the printing process). Converting the whole process to a VBA module (or inserting the necessary 'Run' commands into the existing macro) would definitely be an option if the necessary command were only available through VBA.
    Attached Images Attached Images

  2. #2
    3 Star Lounger
    Join Date
    May 2002
    Location
    Toronto, Ontario, Canada
    Posts
    314
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Change printer for PrintOut (A2K SR1)

    (Edited by HansV to make URL live - see <!help=19>Help 19<!/help>)

    Good Morning David... <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

    I have never had to do this, but I was sure that I'd seen how to somewhere... Doing a search on Google for "vba changing printer" came up with numerous hits... I found the attached file at : http://www.mcwtech.com/downloads.htm

    It's an mdb done in Access 97 and I'm sure you'll have to adapt it... but hopefully it'll help...

    Have a great day!
    Attached Files Attached Files

  3. #3
    3 Star Lounger
    Join Date
    May 2002
    Location
    Toronto, Ontario, Canada
    Posts
    314
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Change printer for PrintOut (A2K SR1)

    <P ID="edit" class=small>(Edited by WendellB on 01-May-03 08:01. activate link - see Help 19)</P> <img src=/S/laugh.gif border=0 alt=laugh width=15 height=15> Help!... I can't stop looking for this now... (When I get a question in my head... look out!!... )

    I wasn't sure whether that file would help you or not... so I found this code at: http://www.erlandsendata.no/english/vba/pr...angeprinter.php

    'Change the default printer
    'This example macro shows how to print a selected document to another printer then the default printer.
    'This is done by changing the property Application.ActivePrinter :

    Sub PrintToAnotherPrinter()
    Dim STDprinter As String
    STDprinter = Application.ActivePrinter
    Application.ActivePrinter = "microsoft fax on fax:"
    ' change printer
    ActiveSheet.PrintOut
    ' prints the active sheet
    Application.ActivePrinter = STDprinter
    ' change back to standard printer
    End Sub

    Let me know how it goes... <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

  4. #4
    5 Star Lounger
    Join Date
    Feb 2001
    Location
    Youngstown, Ohio, USA
    Posts
    705
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Change printer for PrintOut (A2K SR1)

    That looks like what I found by recording a macro in Excel, by hitting 'Record', selecting the 'Print' menu command, and selecting a non-default printer before hitting go. After cleaning things up a little, the following works exceptionally well in Excel:<pre>Application.ActivePrinter = "IBM InfoPrint 40 on Ne00:"
    ActiveWindow.SelectedSheets.PrintOut
    Application.ActivePrinter = "HP LaserJet 1100 on LPT1:"</pre>

    After a little testing in Excel, I converted my existing Access macro to a module and inserted the ActivePrinter codes in the appropriate locations. The problem is, Access does not support the ActivePrinter feature. <img src=/S/sigh.gif border=0 alt=sigh width=15 height=15> If only Access had some macro-recording feature as well!

    My impression was that anything that could be done through the menu could be mimicked by VBA. However, the help file made it look like the menu 'Print' command was just about the only one that could not be done using a DoCmd function.

  5. #5
    5 Star Lounger
    Join Date
    Feb 2001
    Location
    Youngstown, Ohio, USA
    Posts
    705
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Change printer for PrintOut (A2K SR1)

    <P ID="edit" class=small>(Edited by d_rasley on 01-May-03 13:57. Updated to report testing results.)</P>The code contained in the sample database works nice for reading the available printers into a form's drop-down box and changing the default printer as selected. It's a whole lot more than I was looking for, since I don't mind having my code fixed to specific printers instead of prompting. I'm wondering now what difference it might make that the pc is running WinNT as a server instead of a more standard WinOS, since the code reads and writes the default printer information in WIN.INI.

    Update: The sample database did work on the NT computer, even though there was nothing discernable in the WIN.INI file that would indicate which printer was the default. A little bit of work and I should be able to integrate this printer switching process.

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

    Re: Change printer for PrintOut (A2K SR1)

    There was no printer object in Access until 2002. And much as people wish for a macro recorder in Access, what would it record? Macro recorders basically record mouse actions and menu seletions so that you can play them back. In the context of a word processor or a spreadsheet, that makes sense. In Access, there really is no equivalent environment. The closest you can come is to create a regular Access macro (as opposed to a VBA macro in Word or Excel), select the actions you want to take, and then save it as a module, which will convert it into rather primitive code.
    Charlotte

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

    Re: Change printer for PrintOut (A2K SR1)

    I've used printer code on Windows NT, 2000 and XP without problems. I suggest you try it and see what happens. Ini files still exist in the more muscular versions of Windows, and you can still store instructions in them.
    Charlotte

  8. #8
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Atlanta, Georgia, USA
    Posts
    274
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Change printer for PrintOut (A2K SR1)

    Don't know if this is to basic but why not use the page setup in the report to specify a printer.
    Click use specific printer and then select the printer from the list.
    This will then be the printer the report prints to.
    Attached Images Attached Images

  9. #9
    5 Star Lounger
    Join Date
    Feb 2001
    Location
    Youngstown, Ohio, USA
    Posts
    705
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Change printer for PrintOut (A2K SR1)

    Thanks. <img src=/S/bow.gif border=0 alt=bow width=15 height=15> Note to self: <img src=/S/rtfm.gif border=0 alt=rtfm width=24 height=23> <img src=/S/bash.gif border=0 alt=bash width=35 height=39>

    All that I've ever paid attention to on that menu have been the margin and portrait/landscape options. Sometimes it seems so much easier to create a complicated solution than it is to find the simple one. <img src=/S/dizzy.gif border=0 alt=dizzy width=15 height=15>

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

    Re: Change printer for PrintOut (A2K SR1)

    I think the assumption, at least in my case, was that you were trying to do this in an application that might be used on a different machine with different printers and so you needed code. If you are doing it for yourself with full access to the built in menus and dialogs, then it is certainly easier to use the dialog to control the printer selection. Keep in mind thougn, that if you save a report with a specific printer setting, the margin settings will be lost if that printer is not available and you use a different one.
    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
  •