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

tonywatsonhelp

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

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

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,819
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,625
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,765
Messages
5,574,111
Members
412,571
Latest member
Ventura7
Top