austicks84
New Member
- Joined
- May 8, 2018
- Messages
- 11
Hi,
I am using the following code to save the current worksheet as a PDF in the same folder as the spreadsheet is saved, with the filename according to cell B2. It works perfectly on my windows computer. I am wondering if someone could show me how to alter the code so that it would work on a Mac?
Sub PDFActiveSheetNoPrompt()
'for Excel 2010 and later
If Sheets("Rubric Input").Range("AE5") > 0 Then
Dim wsA As Worksheet
Dim wbA As Workbook
Dim strName As String
Dim strPath As String
Dim strFile As String
Dim strPathFile As String
Dim myFile As Variant
On Error GoTo errHandler
Set wbA = ActiveWorkbook
Set wsA = ActiveSheet
'get active workbook folder, if saved
strPath = wbA.Path
If strPath = "" Then
strPath = Application.DefaultFilePath
End If
strPath = strPath & ""
strName = wsA.Range("B2").Value
'create default name for savng file
strFile = strName & ".pdf"
strPathFile = strPath & strFile
'export to PDF in current folder
wsA.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=strPathFile, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
'confirmation message with file info
MsgBox "PDF file has been created: " _
& vbCrLf _
& strPathFile
exitHandler:
Exit Sub
errHandler:
MsgBox "Could not create PDF file"
Resume exitHandler
End If
End Sub
I am using the following code to save the current worksheet as a PDF in the same folder as the spreadsheet is saved, with the filename according to cell B2. It works perfectly on my windows computer. I am wondering if someone could show me how to alter the code so that it would work on a Mac?
Sub PDFActiveSheetNoPrompt()
'for Excel 2010 and later
If Sheets("Rubric Input").Range("AE5") > 0 Then
Dim wsA As Worksheet
Dim wbA As Workbook
Dim strName As String
Dim strPath As String
Dim strFile As String
Dim strPathFile As String
Dim myFile As Variant
On Error GoTo errHandler
Set wbA = ActiveWorkbook
Set wsA = ActiveSheet
'get active workbook folder, if saved
strPath = wbA.Path
If strPath = "" Then
strPath = Application.DefaultFilePath
End If
strPath = strPath & ""
strName = wsA.Range("B2").Value
'create default name for savng file
strFile = strName & ".pdf"
strPathFile = strPath & strFile
'export to PDF in current folder
wsA.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=strPathFile, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
'confirmation message with file info
MsgBox "PDF file has been created: " _
& vbCrLf _
& strPathFile
exitHandler:
Exit Sub
errHandler:
MsgBox "Could not create PDF file"
Resume exitHandler
End If
End Sub