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

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
2,620
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
 

Some videos you may like

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
12,594
Office Version
  1. 2007
Platform
  1. Windows
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.
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
35,811
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
You should use Application.Pathseparator rather than "\"
 

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
2,620
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
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
 

Watch MrExcel Video

Forum statistics

Threads
1,118,344
Messages
5,571,662
Members
412,412
Latest member
NWPhotoExplorer
Top