Snowflake68
Registered User.
- Local time
- Today, 02:24
- Joined
- May 28, 2014
- Messages
- 464
I have found this code on the web that will prompt the SaveAs dialog box when exporting a file but how can I modify it so that it populates the filename with a specific filename such as "Results" plus the current date?
I am using the above code in the transfer spreadsheet code below.
Code:
Public Function saveFileAs() As String
Dim fd As FileDialog, fileName As String
On Error GoTo ErrorHandler
Set fd = Application.FileDialog(msoFileDialogSaveAs)
If fd.Show = True Then
If fd.SelectedItems(1) <> vbNullString Then
fileName = fd.SelectedItems(1)
End If
Else
'Stop Code Execution for Null File String
End
End If
saveFileAs = fileName
'Cleanup
Set fd = Nothing
Exit Function
ErrorHandler:
Set fd = Nothing
MsgBox "Error " & Err & ": " & Error(Err)
End Function
I am using the above code in the transfer spreadsheet code below.
Code:
Private Sub cmdExcelExport_Click()
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "qryData", saveFileAs, True
End Sub
Last edited: