Robert Kendall
Robert Kendall

Reputation: 390

Save Access Report as PDF

Using VBA macro attached to a "Save File" button on a form. Would like two things: In the SaveAs dialog box, I would like the default fil name to be "Inspections Due" and the default file type to be PDF.The following code opens the SaveAs dialog, with no default name, and file type is .

Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogSaveAs)
If fd.Show Then

    DoCmd.OutputTo acOutputReport, "Inspections Due", acFormatPDF, 
fd.SelectedItems(1), True

End If

Revised code below:

Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogSaveAs)
With fd
    .InitialFileName = "Inspections Due"
    .Filters.Add "PDF", "*.PDF"
    .FilterIndex = 1
End With

If fd.Show Then
    DoCmd.OutputTo acOutputReport, "Inspections Due", acFormatPDF, 
fd.SelectedItems(1), True
End If

End Sub

I have tried different values for filter index, including, 1,2,25 and get the same error.

Upvotes: 1

Views: 1266

Answers (1)

Zam
Zam

Reputation: 2940

In the SaveAs dialog box, I would like the default fil name to be "Inspections Due"

Set fd = Application.FileDialog(msoFileDialogSaveAs)
fd.InitialFileName = "Name you need"

Upvotes: 2

Related Questions