# VBA to print to pdf is sending to printer (Mac OS)



## ALO_FLX (Dec 28, 2022)

Hi,

Apologies if this is answered elsewhere but I've searched high and low for the answer to this one and even thought I'd found it when I found a Ron De Bruin post on it so tweaked my code to align with his and still no luck.

Essentially I have a workbook that runs a list through a template and prints each employee's payslip. However, I moved to Mac and it no longer worked hence my search.

Below is the code and any help would be massively appreciated.

Thanks in advance.


```
Sub Print_All_To_PDF()

' Print_to_PDF Macro

Dim strValidationRange As String
Dim rngValidation As Range
Dim rngDepartment As Range
    
Dim FileName As String
Dim FolderName As String
Dim Folderstring As String
Dim FilePathName As String

' Turn off screen updating
Application.ScreenUpdating = False

' Identify the source list of the data validation
strValidationRange = Worksheets("Payslip Template").Range("A11").Validation.Formula1
Set rngValidation = Range(strValidationRange)

' Set the value in the selection cell to each selection in turn
' and print the results.
For Each rngDepartment In rngValidation.Cells
Worksheets("Payslip Template").Range("A11").Value = rngDepartment.Value
    'Name of the folder in the Office folder
    FolderName = "Payslips"
    'Name of the pdf file
    FileName = "Payslip - " & Worksheets("Sheet Data").Range("B5") & ". " & Worksheets("Payslip Template").Range("A9").Value _
    & " - " & Worksheets("Payslip Template").Range("A11").Value & ".pdf" _

    FilePathName = FolderName & Application.PathSeparator & FileName

    'expression A variable that represents a Workbook, Sheet, Chart, or Range object.
    'the parameters are not working like in Excel for Windows
    Worksheets("Payslip Template").ExportAsFixedFormat Type:=xlTypePDF, FileName:= _
    FilePathName, Quality:=xlQualityStandard, _
    IncludeDocProperties:=True, IgnorePrintAreas:=False
Next
' Turn screen updating back on
Application.ScreenUpdating = True

MsgBox "Payslip run complete", vbOKOnly, "Payroll"

End Sub
```


----------



## RoryA (Dec 28, 2022)

So from your title, you are saying that the ExportToFixedFormat line is actually printing the file on your printer?


----------



## ALO_FLX (Dec 28, 2022)

Correct, took me a while to suss the issue as the printer was offline.


----------



## RoryA (Dec 28, 2022)

Which version/build of Office are you running?


----------



## ALO_FLX (Dec 28, 2022)

RoryA said:


> Which version/build of Office are you running?


365


----------



## RoryA (Dec 28, 2022)

I know you have 365 as it's in your profile, but which actual version number and build is it? Different features (and bugs) are present in different builds.


----------



## ALO_FLX (Dec 29, 2022)

RoryA said:


> I know you have 365 as it's in your profile, but which actual version number and build is it? Different features (and bugs) are present in different builds.


Apologies, I wasn't 100% on what you were after.

In terms of Version Number it is 16.68. 

Build wise, I'm on Ventura 13.0.1

Hopefully this was the info you were after but please let me know if there is anything else. Appreciate any help you can offer.

Cheers


----------

