VBA copy range to new workbook save as path and filename

  • This should work


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

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


    Code
    1. 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
    1. If Application.ActivePrinter <> "NPI140D8A (HP LaserJet 400 M401n) on Ne00:" Then _
    2. 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
    1. 'If Application.ActivePrinter <> "NPI140D8A (HP LaserJet 400 M401n) on Ne00:" Then _
    2. 'Application.ActivePrinter = "NPI140D8A (HP LaserJet 400 M401n) on Ne00:"
    3. Application.Dialogs(xlDialogPrinterSetup).Show
    4. wsO.PrintOut
    5. 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