Although I used this routine to export to Excel it could in theory be used with any format supported by DoCmd.Output or really any statement which output a file.
Expand|Select|Wrap|Line Numbers
- Private Sub cmdSendtoExcel_Click()
- Dim fd As FileDialog
- Dim Title As String
- Dim vrtSelectedItem As Variant
- Set fd = Application.FileDialog(msoFileDialogSaveAs)
- With fd
- .AllowMultiSelect = False
- .Title = "Save File"
- .InitialFileName = "Name Of Report " & Format(Now(), "ddmmyyyyhhnn") & ".xls"
- If .Show = True Then
- For Each vrtSelectedItem In .SelectedItems
- DoCmd.OutputTo acOutputQuery, "query or table name", acFormatXLS, vrtSelectedItem
- Next vrtSelectedItem
- Else
- MsgBox "No file was selected"
- End If
- End With
- End Sub
Mary