Problem printing on Excel for Mac 2016/2019/365

mcomp72

Active Member
Joined
Aug 14, 2016
Messages
275
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2011
Platform
  1. Windows
  2. MacOS
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!!

https://www.dropbox.com/s/lsrsui1st2bomxq/TestWorkbook-PrintAndPDF_Mac.xlsm?dl=0
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
FYI -- since I haven't received any replies here, I'm going to post this to some other forums.
 
Upvote 0
In that case can you please supply links to any other sites where you have asked this.
Thanks
 
Upvote 0
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.

Code:
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


ThisWorkbook.Sheets("Sheet1").Activate


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:
Upvote 0

Forum statistics

Threads
1,213,484
Messages
6,113,920
Members
448,533
Latest member
thietbibeboiwasaco

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top