Save As PDF on Mac

agrissy

New Member
Joined
Sep 4, 2018
Messages
4
Hello!

I have been trying to find the VBA code for the Mac as it is working well on Windows. Here is the VBA code for Windows:

Sub SaveAsPDF()
Dim strDesktop As String
strDesktop = CreateObject("WScript.Shell").<wbr>SpecialFolders("Desktop")
ThisWorkbook.<wbr>ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=strDesktop & "\invoice " & Format(Date, "mm.dd.yyyy") & ".pdf"
Range("F3").Value = Range("F3").Value + 1
Range("E14:J24").ClearContents
End Sub

This code will save the entire worksheet, I did change ThisWorksbook to ThisActivesheet, but it did not work as I only want to save one active sheet called "Invoice," not the entire worksheet. I would like to know how to save as the PDF on Mac? I also would like to see if it is possible for me to type a filename manually after before I save the PDF. Is it possible to save it under Documents rather than on the desktop? It would be challenging to track invoices if I use to like this invoice 28.09.2018.pdf. I want to input the name company, invoice #, and date. Last, when I close the Excel and open it again, the invoice number will be saved as previous. Is there a way to increment the invoice number when opening the Excel?

Thanks in advance!
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

Forum statistics

Threads
1,215,067
Messages
6,122,949
Members
449,095
Latest member
nmaske

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