Share via

Excel Print Macro

Anonymous
2019-09-26T19:09:44+00:00

Just a note, I don't know too much about programming in VBA and most of the macros I've used have been copied from other sources.  Here's the issue I'm dealing with

Context:

  • I designed a tool using Excel for some of our workers to print out labels.  To accomplish this I used a macro to print specifically to a label printer at each workers bench once a button is clicked.
  • To enter the value for the information on the label, I also created a sheet with scan-able barcodes of part numbers that also need to be printed out. It doesn't need to be printed that often, but the option needs to be there. To accomplish this  I used a macro to select an office printer to print this sheet out when a button is clicked.
  • When going back to print the label, the macro will switch back to the label printer because the macro will look for the printer name.
  • The label printer is the default printer in this scenario

Problem:

  • This tool exists on our corporate document control center and can only be launched from there.  This is because my company is ISO certified.
  • In order for the tool to be used, once it is launched from our document control center I have to run a macro to get the printer name for the label printer and copy/paste that into a macro to set the printer. This is too complicated to expect someone to do on a daily basis.

Question: 

  • Because I am dealing with a label printer for each individual Is there any way or some code that will generally select the default printer instead of having to find, copy and paste the printer name into a macro in order to work?  The macro would also have to go back to the label printer if the separate office printer is used.

Here are the macros I am using to print to the label printer

  • Sub SetLabelPrinter()

Application.ActivePrinter = "ZDesigner GC420d (EPL) on Ne00:"

End Sub

  • Sub PrintInitial()

     ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _

        IgnorePrintAreas:=False

End Sub

  • Sub PrintLabel()

    SetLabelPrinter

    PrintInitial

End Sub

Any help would be greatly appreciated.

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

3 answers

Sort by: Most helpful
  1. Anonymous
    2019-10-02T19:23:33+00:00

    I don't know of code to accomplish, what you want.

    0 comments No comments
  2. Anonymous
    2019-10-02T19:14:26+00:00

    Hi Francis,

    Thank You for your reply.  In this case I would like to try and avoid dialog windows if at all possible.  One in necessary so I use it for the requirement for the Office printer.

    I guess what I'm getting at is that I would like to print to whatever the default printer is set to.  The default printer shouldn't change even if a different printer is selected.  

    I would think this would be easy to accomplish but the answer hasn't been easy to find.

    0 comments No comments
  3. Anonymous
    2019-09-27T12:35:16+00:00

    The application that I have the following code in, is used by several people. We all have a common printer that is used. Possibly you could this code with some modifications.

    Sub Print_Dialog_Box()

    Dim bTemp As Boolean

    'Calls the normal print window.

    bTemp = Application.Dialogs(xlDialogPrint).Show

    End Sub

    The code calls the printer(s) that the user has available on their unit. It calls the normal print dialog window.

    Good luck

    0 comments No comments