Print to PDF on a Mac

Benny236

New Member
Joined
Feb 29, 2016
Messages
33
Hi all.

My friend wrote me a macro to export data in templates to PDFs. Simple enough task, but neither of us can get it to work on my Mac. Is it possible to do so? Code below. Thanks in advance!

Sub GetDataGenerateInvoices()


Dim DealerCounter As Integer
Dim DealerCodePos As Integer
Dim strFile As String
Dim strPathFile As String
Dim strSheet As String
Dim strInvoiceTemplate As String
Dim MasterBook As Workbook
Dim SourceBook As Workbook
Dim rngSourceRange As Range
Dim rngDestination As Range


Set MasterBook = ActiveWorkbook
With Application.FileDialog(msoFileDialogOpen)
.Filters.Clear
.Filters.Add "Excel 2007-13", "*.xlsx; *.xlsm; *.xlsa"
.AllowMultiSelect = False
.Show
If .SelectedItems.Count > 0 Then
Workbooks.Open .SelectedItems(1)
Set SourceBook = ActiveWorkbook

'Get sales data and copy
Set rngSourceRange = Application.Range("Current!A6:F3000")
MasterBook.Activate
Set rngDestination = Application.Range("Current!A6")
rngSourceRange.Copy rngDestination
rngDestination.CurrentRegion.EntireColumn.AutoFit

'Get invoice numbers and copy
SourceBook.Activate
Set rngSourceRange = Application.Range("Current!AB4:AB50")
MasterBook.Activate
Set rngDestination = Application.Range("Current!AB4")
rngSourceRange.Copy rngDestination
rngDestination.CurrentRegion.EntireColumn.AutoFit

'Get addresses and copy
SourceBook.Activate
Set rngSourceRange = Application.Range("Addresses!A5:B100")
MasterBook.Activate
Set rngDestination = Application.Range("Addresses!A5")
rngSourceRange.Copy rngDestination
rngDestination.CurrentRegion.EntireColumn.AutoFit

SourceBook.Close False
End If
End With

'create and save invoice for all dealer codes
For DealerCounter = 1 To Worksheets("Invoice 1").Range("K18").Value

'used to cycle through the unique dealer codes
DealerCodePos = DealerCounter + 3

If Not Worksheets("Current").Range("AA" & DealerCodePos).Value = "RM" Then

'change dealer code in worksheet
Worksheets("Current").Range("P6").Value = Worksheets("Current").Range("AA" & DealerCodePos).Value

'wait 2 seconds to allow update of cells
Application.Wait (Now + TimeValue("0:00:00"))

'create PDF file name
strFile = Worksheets("Invoice 1").Range("F10").Value & ".pdf"
strPathFile = ActiveWorkbook.Path & "" & strFile

'choose which invoice template to use
strSheet = Worksheets("Invoice 1").Range("L18").Value
strInvoiceTemplate = "Invoice " & strSheet

'export to PDF
Worksheets(strInvoiceTemplate).ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=strPathFile, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False

End If
Next
End Sub
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

Forum statistics

Threads
1,214,559
Messages
6,120,208
Members
448,951
Latest member
jennlynn

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