Forum Discussion
dominiccronshaw
Nov 02, 2025Copper Contributor
VBA trouble with Export as Fixed Format
Hi folks - I'm struggling to get this code for export as fixed format to work. My aim is to use it to churn through 150 names in a dropdown (data validation using a reference to a named rang...
NikolinoDE
Nov 04, 2025Platinum Contributor
Classic Excel-on-Mac VBA snag — especially with ExportAsFixedFormat and SharePoint/OneDrive paths.
Sub PrintAllVariablePayoutPDFs_MacSafe()
Dim DropDown As Range
Dim IndivName As Range
Dim NamesList As Range
Dim PDFName As String
Dim PDFPath As String
Dim FullPath As String
' Disable screen updates for speed
Application.ScreenUpdating = False
' Dropdown location
Set DropDown = Range("G2")
' List of all names (from validation)
Set NamesList = Evaluate(DropDown.Validation.Formula1)
' Use a valid local path - ensure it exists first
PDFPath = "/Users/dominiccronshaw/Library/CloudStorage/OneDrive-COMPANY/GTM Operations/Commissions/2025 Q3/Payout PDFs/"
If Right(PDFPath, 1) <> "/" Then PDFPath = PDFPath & "/"
If Dir(PDFPath, vbDirectory) = "" Then
MsgBox "PDF output folder not found: " & PDFPath, vbCritical
Exit Sub
End If
' Loop through all names in list
For Each IndivName In NamesList
DropDown.Value = IndivName.Value
DoEvents ' let Excel update dependent cells
' Refresh PDF name each time (in case K4 changes)
PDFName = Range("K4").Value
FullPath = PDFPath & PDFName & ".pdf"
' Optional debug check
Debug.Print "Saving PDF to: " & FullPath
' Export as PDF (Mac-safe)
On Error Resume Next
ActiveSheet.ExportAsFixedFormat _
Type:=xlTypePDF, _
FileName:=FullPath, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
If Err.Number <> 0 Then
MsgBox "Error saving PDF for " & IndivName.Value & vbCrLf & _
"Path: " & FullPath & vbCrLf & _
"Error: " & Err.Description, vbCritical
Err.Clear
End If
On Error GoTo 0
Next IndivName
Application.ScreenUpdating = True
MsgBox "All PDFs exported successfully!", vbInformation
End SubMake sure the output folder exists. Excel won’t create directories.
Avoid spaces or punctuation in folder names if possible.
The local OneDrive path on Mac must be mounted under /Users/.../Library/CloudStorage/OneDrive-YourOrgName/.
If the script appears to “do nothing”, open the VBA Immediate Window (Cmd+Option+I) to check the Debug.Print output — it will show exactly where it’s trying to save.
This is a suggestion.
My answers are voluntary and without guarantee!
Hope this will help you.