Allow for user pressing cancel in File/Save API

P

Phil Trumpy

I am using Access 2003 on Windows XP.

I am currently using the Windows File Open/Save Dialog box API to let a user
select where to save an excel file. It works great, but I would like to
inlcude code to allow for a user to cancel the save and return to the form
without anything happening. I have tried a couple different things but
can't get the desired actions to take place. I copied the code from mvps.org
for the API and am using the following code in the application.

Private Sub cmdExport_Click()
Dim strSaveFilename As String
Dim strRptName As String
Dim strFilter As String

strQryName = "qryDynamicExcess"

'Ask for SaveFileName
strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.xls)", "*.xls")
strSaveFilename = ahtCommonFileOpenSave( _
OpenFile:=False, _
Filter:=strFilter, _
Flags:=ahtOFN_OVERWRITEPROMPT Or ahtOFN_READONLY)

strOutputFilename = strSaveFilename
DoCmd.OpenForm "frmPleaseWait"
DoCmd.TransferSpreadsheet acExport, , strQryName, strOutputFilename, True

Call FormatExcel
'If Right(strRptOutputLocation, 1) <> "\" Then
' strRptOutputLocation = strRptOutputLocation + "\"
'End If

DoCmd.Close acForm, "frmPleaseWait"

Where would I put the code to allow for a cancel?

Thanks in advance for your help.
 

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