Is there a macro to print to pdf using excel mac (Microsoft 365)?

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,194
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi Everyone,
not sure if this can be done but I'm look for a macro to turn Sheet"Report" into a pdf and name it the name value in D4.
i need it to work on a mac and pc (or just mac)

please help if you can

Thanks

Tony
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Try this:

VBA Code:
Sub Macro2()
  Dim sName As String
  sName = ThisWorkbook.Path & "\" & Sheets("Report").Range("D4").Value & ".pdf"
  Sheets("Report").ExportAsFixedFormat xlTypePDF, sName, 0, True, False, , , False
End Sub

If you have problems, you could make a macro recording, save the sheet as pdf, stop the macro, the generated code paste it here to adapt the name.
 
Upvote 0
You should use Application.Pathseparator rather than "\"
 
Upvote 0
Thanks guys but I've tried my pc version but it debugs out.
was wounding if anyone knew how to get a mac to do it but I'll play around with it for a while.
thanks
Tony
 
Upvote 0

Forum statistics

Threads
1,214,919
Messages
6,122,260
Members
449,075
Latest member
staticfluids

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