none
VBA / Macro to Print Form to Specific Printer - Access RRS feed

  • Question

  • Hi,

    I am trying to add a button to form that will print out the active form to a specific printer on my network (one that is not my default printer). Any advice? I have tried the below, as I have seen on some other threads:

    1) Set button Macro to "Run Code"

    2) Entered code name as "=MyPrint()"

    3) Created the following VBA Code:

    Sub MyPrint()
    Dim sCurrentPrinter As String
    Const MyPrinter As String = "secure on SW100735.americas.bmw.corp"
    sCurrentPrinter = Application.ActivePrinter
    Application.ActivePrinter = MyPrinter
    DoCmd.PrintOut
    Application.ActivePrinter = sCurrentPrinter
    End Sub

    I am not getting any errors here, but the document is not being sent to the printer.

    Any help would be greatly appreciated!!

    • Moved by Steve Fan Thursday, December 21, 2017 2:47 AM relocate
    Wednesday, December 20, 2017 7:11 PM

All replies

  • Hi,

    Welcome to the Microsoft Office 2010 Planning, Deployment, and Compatibility forum. This forum focuses on non-programming questions related to Microsoft Office applications. Since your query is more related to VBA/Macro, I'll move it to a more appropriate forum:

    https://social.msdn.microsoft.com/Forums/office/en-US/home?forum=accessdev

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.

    Regards,

    Steve Fan


    Please remember to mark the replies as answers if they helped.
    If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.


    • Edited by Steve Fan Thursday, December 21, 2017 2:47 AM
    Thursday, December 21, 2017 2:45 AM
  • Hi spdekold,

    did you check that the value you are passing for the MyPrinter is correct for that printer?

    if no you can verify it.

    you can also try to print the all printers using Application.Printer to check that device is available or not.

    if it is available in the list then you can also try to pass the index number for it like below.

    Set Application.Printer = Application.Printers(0) 
    

    try to make a test and let me know whether the value for printer is correct and is available in the list or not.

    we will try to provide you further suggestions to solve the issue.

    Reference:

    Application.Printer Property (Access)

    Regards

    Deepak 


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, December 25, 2017 2:06 AM
    Moderator
  • Hi spdekold,

    is your issue solved?

    I find that you did not follow up this thread after posting the issue.

    if your issue is solved then I suggest you to post your solution and mark it as an answer.

    if your issue is still exist then try to refer the solution given by the me.

    if then also you have any further questions then let me know about it.

    I will try to provide further suggestions to solve the issue.

    Thanks for your understanding.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, January 2, 2018 9:15 AM
    Moderator