Problem printing on Excel for Mac 2016/2019/365


Board Regular
Aug 14, 2016
I'm making a workbook for both Windows & Mac. I have a button in my workbook that allows them to PRINT worksheets, and another that allows them to make a PDF of worksheets.

Both buttons work perfectly on Windows. On Mac 2016/2019/365, the PDF button works fine. It’s the PRINT button that sometimes causes a problem. It doesn't work properly when the user has pressed the PDF button before pressing the PRINT button. In that case, the .PrintOut line of code either gives an error, or saves a PDF file instead of printing.

If I close the workbook and reopen it, it will print fine UNTIL I create a PDF, and then the problem happens again. I feel like this must be a bug in Excel, but am not 100% sure. I can only test it on my one Mac computer, so I know it's possible it might have something to do with my computer.

I have created a new workbook to test this. This one is only one worksheet and is very simple. I would like to ask the community here if they'd be willing to test it for me. (You need to have Excel for Mac 2016, 2019, or 365.)

You can download the file at the below link. There are instructions on the worksheet explaining the three steps you should follow. Please post your results back here

Thank you! It is much appreciated!!

Some videos you may like

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).


Board Regular
Aug 14, 2016
FYI -- since I haven't received any replies here, I'm going to post this to some other forums.


MrExcel MVP, Moderator
Jun 12, 2014
Office Version
In that case can you please supply links to any other sites where you have asked this.


Board Regular
Aug 14, 2016
By the way, if anyone would be willing to try it on their Mac but would rather not download the test workbook I created, here is the code you could insert into a new workbook to test it.

Sub PrintButton()

'this should send Sheet1 to the default printer
ThisWorkbook.Sheets("Sheet1").PrintOut Preview:=False, IgnorePrintAreas:=False

End Sub

Sub PDFButton()

'this should create a PDF file of Sheet1 on the Desktop of the Mac

Dim UserName As String
Dim FileNameAndPath As String


UserName = MacScript("do shell script ""echo $USER""")

FileNameAndPath = "/Users/" & UserName & "/Desktop/TestPDF.pdf"

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
FileNameAndPath, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False

End Sub
The way to test it is:

  1. Run the PrintButton sub. It should send "Sheet1" to your printer.
  2. Run the PDFButton sub. It should create a PDF of "Sheet1" on your desktop.
  3. Run the PrintButton sub again. This is where the problem is happening for me. I am curious if it works properly for you, or if you receive an error? I received Run-time 1004 error. (I have seen in some circumstances that instead of it printing the sheet here or throwing the error, it makes a PDF when it gets to the .PrintOut line.)
Last edited:

Watch MrExcel Video

Forum statistics

Latest member

This Week's Hot Topics

  • Timer in VBA - Stop, Start, Pause and Reset
    [CODE=vba][/CODE] Option Explicit Dim CmdStop As Boolean Dim Paused As Boolean Dim Start Dim TimerValue As Date Dim pausedTime As Date Sub...
  • how to updates multiple rows in muliselect listbox
    Hello everyone. I need help with below code. code is only chaning 1st row in mulitiselect list box. i know issue with code...
  • Delete Row from Table
    I am trying to delete a row from a table using VBA using a named range to find what I need to delete. My Range is finding the right cell. In the...
  • Assigning to a variable
    I have a for each block where I want to assign the value in column 5 of the found row to the variable Serv. [CODE=vba] For Each ws In...
  • Way to verify information
    Hi All, I don't know what to call this formula, and therefore can't search. I have a spreadsheet with information I want to reference...
  • Active Cell Address – Inactive Sheet
    How to use VBA to get the cell address of the active cell in an inactive worksheet and then place that cell address in a location on the current...