You could use a worksheet as a scratch sheet or create one and delete it as I did.
Sub ken()
Dim Rng As Range, thisSheet As Worksheet, ws As Worksheet, FileName As String
FileName = ActiveWorkbook.Path & "\ken.pdf" '"Macintosh HD:Users:Crystal:Desktop:Test2.pdf"
Set Rng = Selection.SpecialCells(xlCellTypeVisible)
Set thisSheet = ActiveSheet
Set ws = Worksheets.Add(after:=Worksheets(Worksheets.Count))
If Rng Is Nothing Then
MsgBox "Please select a range and try again."
Exit Sub
End If
Rng.Copy Range("A1")
PublishToPDF ActiveSheet.UsedRange, ActiveWorkbook.Path & "\ken.pdf"
thisSheet.Select
Application.DisplayAlerts = False
ws.Delete
Application.DisplayAlerts = True
Shell "cmd /c " & """" & FileName & """", vbNormalFocus
End Sub
Sub PublishToPDF(o As Object, Optional fn As String = "")
Dim rc As Variant
If fn = "" Then
rc = Application.GetSaveAsFilename(fn, "PDF (*.pdf), *.pdf", 1, "Publish to PDF")
Else: rc = fn
End If
If rc = "" Or rc = False Then Exit Sub
o.ExportAsFixedFormat Type:=xlTypePDF, FileName:=rc _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=False
End Sub