T
Tony
I have a CommonDialog control on a form to save the
database into an excel spreadsheet. When I click on the
Download button, the SaveAs Dialog box appears, but I it
doesn't save the file. this is my code:
Am I forgetting something? Thanks
Private Sub cmdDownloadList_Click()
'Set the common dialog box
Dim cdl As CommonDialog
On Error GoTo ErrorDownload
Set cdl = New CommonDialog
cdl.Filter = _
"Excel Files (*.xls)|" & "*.xls|" & _
"Text Files (*.txt)|" & "*.txt|" & _
"All Files (*.*)|" & "*.*|"
cdl.FilterIndex = 1
cdl.DialogTitle = "Download GEM Customers List"
cdl.ShowSave
'destroy the common dialog box
ErrorDownload_Exit:
Set cdl = Nothing
Exit Sub
ErrorDownload:
Select Case Err.Number
Case cdlCancel
'Cancelled
Resume ErrorDownload_Exit
Case Else
MsgBox "Error: " & Err.Description & "(" &
Err.Number & ")"
End Select
MsgBox "The file has been saved to:" & vbCrLf &
cdl.FileName, vbInformation, "Download Complete"
Resume ErrorDownload_Exit
End Sub
database into an excel spreadsheet. When I click on the
Download button, the SaveAs Dialog box appears, but I it
doesn't save the file. this is my code:
Am I forgetting something? Thanks
Private Sub cmdDownloadList_Click()
'Set the common dialog box
Dim cdl As CommonDialog
On Error GoTo ErrorDownload
Set cdl = New CommonDialog
cdl.Filter = _
"Excel Files (*.xls)|" & "*.xls|" & _
"Text Files (*.txt)|" & "*.txt|" & _
"All Files (*.*)|" & "*.*|"
cdl.FilterIndex = 1
cdl.DialogTitle = "Download GEM Customers List"
cdl.ShowSave
'destroy the common dialog box
ErrorDownload_Exit:
Set cdl = Nothing
Exit Sub
ErrorDownload:
Select Case Err.Number
Case cdlCancel
'Cancelled
Resume ErrorDownload_Exit
Case Else
MsgBox "Error: " & Err.Description & "(" &
Err.Number & ")"
End Select
MsgBox "The file has been saved to:" & vbCrLf &
cdl.FileName, vbInformation, "Download Complete"
Resume ErrorDownload_Exit
End Sub