Here's one that I think is something minor I am overlooking. I am trying to give the users an option to export a report in either Excel or PDF. The Excel DoCmd.TransferSpreadsheet works fine, but the PDF DoCmd.OutputTo brings up a second save window after accepting the first. I MUST have the file dialog option as this will be issued for use in both my local office and internationally, so I cannot force an output location.
cboReports is where the user selects the report. Column(0) is the report name and appears in the combo box. Column(1) is the report object name. Column(2) is the query onject name that populates the report.
cboFormat is where the user selects the format they want to export to. Column(0) is the format name (Excel or PDF). Column(1) is the file extension.
Code:
Private Sub cmdExport_Click()
Dim fd As FileDialog
Dim FN As String
Dim vrtSelectedItem As Variant
Set fd = Application.FileDialog(msoFileDialogSaveAs)
FN = [Forms]![frmReportMenu]![sfrSystems].[Form]![Proj] & " " & Me.cboReports.Column(0) & Me.cboFormat.Column(1)
With fd
.AllowMultiSelect = False
.Title = "Save Report"
.InitialFileName = FN
If .Show = True And Me.cboFormat.Column(0) = "Excel" Then
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, Me.ExportExcel, [Forms]![frmReportMenu]![sfrSystems].[Form]![Proj] & " " & Me.cboReports.Column(0), Yes
ElseIf .Show = True And Me.cboFormat.Column(0) = "PDF" Then
DoCmd.OutputTo acOutputReport, Me.ExportPDF, acFormatPDF, .SelectedItems(1)
End If
End With
End Sub