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
Douglas J. Steele - 25 Jul 2003 19:45 GMT
All that code does is return the name of the file to use. You have to write
your own code to actually save the file.
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
> I have a CommonDialog control on a form to save the
> database into an excel spreadsheet. When I click on the
[quoted text clipped - 36 lines]
> Resume ErrorDownload_Exit
> End Sub
Larry Daugherty - 28 Jul 2003 03:59 GMT
If you haven't got the CDL going yet I suggest you try the code supplied by
Ken Getz on http://mvps.org/access. It includes a TestIt routine that
demonstrates how to use the code. By using that code you should avoid OS
glitches and various versioning issues.
hth

Signature
-Larry-
--
> I have a CommonDialog control on a form to save the
> database into an excel spreadsheet. When I click on the
[quoted text clipped - 36 lines]
> Resume ErrorDownload_Exit
> End Sub