• Change printer for PrintOut (A2K SR1)

    • This topic has 9 replies, 4 voices, and was last updated 22 years ago.
    Author
    Topic
    #386812

    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.

    Viewing 2 reply threads
    Author
    Replies
    • #672626

      (Edited by HansV to make URL live – see Help 19)

      Good Morning David… smile

      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%5B/url%5D

      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!

      • #672726

        (Edited by d_rasley on 01-May-03 13:57. Updated to report testing results.)

        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.

        • #672873

          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.

    • #672629

      (Edited by WendellB on 01-May-03 08:01. activate link – see Help 19)

      laugh 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%5B/url%5D

      ‘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… smile

      • #672723

        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:

        Application.ActivePrinter = "IBM InfoPrint 40 on Ne00:"
        ActiveWindow.SelectedSheets.PrintOut
        Application.ActivePrinter = "HP LaserJet 1100 on LPT1:"

        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. sigh 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.

        • #672871

          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.

    • #672991

      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.

      • #673002

        Thanks. bow Note to self: rtfm bash

        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. dizzy

        • #673040

          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.

    Viewing 2 reply threads
    Reply To: Reply #673002 in Change printer for PrintOut (A2K SR1)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information:




    Cancel