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

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney


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

  • Finding issue in If elseif else with For each Loop
    Finding issue in If elseif else with For each Loop I have tried this below code but i'm getting in Y column filled with W005. Colud you please...
  • MsgBox Error
    Hi Guys, I have the below error show up when i try and run my macro in File1 but works fine if i copy and paste the same code into file2. [ATTACH...
    My Cell Format is [B]""0.00" Cr". [/B]But in the cell, it is showing 123.00 for editing. (123 is entry figure). (Data imported from other...
  • Show numbers nearly the same
    Is this possible. I have a number that can change very time eg 0.00001234 Then I have a lot of numbers 0.0000001, 0.0000002, 0.00000004...
  • Please i need your help to create formula
    I need a formula in cell B8 to do this >>if b1=1 then multiply ( cell b8) by 10% ,if b1=2 multiply by 20%,if=3 multiply by 30%. Thank you in...
  • Got error while adding column and filter
    Got error while adding column and filter In column Z has some like "Success" and "Error". I want to add column in AA if the Z cell value is...