I'm trying to save a sheet in the spreadsheet as a PDF, when it's ran I get the grant permission dialog box as well as the dialog to set the location and specify the file name. The file names are pre-set based on the FN value passed.
Example: FN = test.pdf
I want to completely bypass the both dialog boxes, how can I do this? Do I make adjustments in my trust center? I just need it to save it as test.pdf
Example: FN = test.pdf
I want to completely bypass the both dialog boxes, how can I do this? Do I make adjustments in my trust center? I just need it to save it as test.pdf
Code:
Sub MacPDF(FN As String)
Dim fileAccessGranted As Boolean
Dim filePermissionCandidates
Dim wsPath As String
wsPath = Application.ThisWorkbook.Path
If Application.Version >= 15 Then
' Will prompt user for access to folder where workbook is located (only once)
Application.DisplayAlerts = False
filePermissionCandidates = Array(wsPath)
fileAccessGranted = GrantAccessToMultipleFiles(filePermissionCandidates)
sName = Application.GetSaveAsFilename(FN)
If sName <> "False" Then
ActiveWorkbook.SaveAs sName, FileFormat:=xlPDF
End If
End If
End Sub