VBA copy range to new workbook save as path and filename

  • This should work


    Code
    Dim CurrentPrinter As String
    CurrentPrinter = Application.ActivePrinter
    If Application.ActivePrinter <> "NPI140D8A (HP LaserJet 400 M401n) on Ne00:" Then _
    Application.ActivePrinter = "NPI140D8A (HP LaserJet 400 M401n) on Ne00:"
    wsO.PrintOut ''/// use PrintPreview if you want to view before printing
    Application.ActivePrinter = CurrentPrinter

    Your code has a comma in it. It should be just ws0.Printout


    Code
    wsO.PrintOut , preview = False
  • Roy,

    I plugged in what you sent and I still get the same run time error. I read where the port number (Ne00 in this case) will change from Ne00 thru Ne16. I verified that the printer I am testing with still had Ne00 before I tried the code.

    I will keep trying. Thank you!!

  • It's the "Application.ActivePrinter" line right before the wsO.printout.

  • Code
    If Application.ActivePrinter <> "NPI140D8A (HP LaserJet 400 M401n) on Ne00:" Then _
    Application.ActivePrinter = "NPI140D8A (HP LaserJet 400 M401n) on Ne00:"

    This line is split see the underscore. Has it copied properly?

  • Hey Roy,

    I think I have found a temporary solution. I didn't and still don't really want the user to have to do anything but fill in the blanks and hit submit but..... I made the changes below . We will have to make sure the printer we want to use is set up on the users kiosks if we end up using this until the Application.ActivePrinter is figured out. I have only tested it on my computer so far but will try it on one of the kiosks today. I appreciate your help and will keep trying to get the original plan to work in the meantime.


    Code
    'If Application.ActivePrinter <> "NPI140D8A (HP LaserJet 400 M401n) on Ne00:" Then _
    'Application.ActivePrinter = "NPI140D8A (HP LaserJet 400 M401n) on Ne00:"
    Application.Dialogs(xlDialogPrinterSetup).Show
    wsO.PrintOut
    Application.ActivePrinter = CurrentPrinter
  • Hi Roy,

    Still no luck with the "Application.ActivePrinter" portion of the code. I will keep trying but wanted to drop back in to say Thank You again for all your help.

    I appreciate your time and guidance.

    Best Regards,

    Tim

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!