CommonDialog Control

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
 
N

Neil

Yes, You have to do the work to save the file. The dialog just stores the
path as a string to use later on in the procedure (code actually stops until
the dialog control closes).

HTH,

Neil.
 
T

Tony

Would you tell me how to code that? Thanks
-----Original Message-----
Yes, You have to do the work to save the file. The dialog just stores the
path as a string to use later on in the procedure (code actually stops until
the dialog control closes).

HTH,

Neil.




.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top