再用CommonDialog控件显示"另存为"对话框,设置了CommonDialog的filename属性,然后执行复制,可是当我点取消时,仍然会拷贝,请问又什么办法可以点取消时不执行该操作cdlSave.CancelError = False
cdlSave.FileName = gcststrOutPutScanFileName '我定以的一个文件名常量
cdlSave.Flags = ccdlOFNOverwritePrompt
cdlSave.Filter = "Excel Files (*.xls)|*.xls"
cdlSave.ShowSaveFileCopy strPath, cdlSave.FileName
cdlSave.FileName = gcststrOutPutScanFileName '我定以的一个文件名常量
cdlSave.Flags = ccdlOFNOverwritePrompt
cdlSave.Filter = "Excel Files (*.xls)|*.xls"
cdlSave.ShowSaveFileCopy strPath, cdlSave.FileName
CommonDialog1.CancelError = True
On Error GoTo ErrHandler
CommonDialog1.FileName = "gcststrOutPutScanFileName" '我定以的一个文件名常量
CommonDialog1.Flags = 1
CommonDialog1.Filter = "Excel Files (*.xls)|*.xls"
CommonDialog1.ShowSaveMsgBox "ok"
Exit SubErrHandler:
' 用户按了“取消”按钮
MsgBox "取消"
Exit Sub
End Sub
CommonDialog1.CancelError = True
On Error GoTo ErrHandler
CommonDialog1.FileName = "gcststrOutPutScanFileName" '我定以的一个文件名常量
CommonDialog1.Flags = 1
CommonDialog1.Filter = "Excel Files (*.xls)|*.xls"
CommonDialog1.ShowSaveMsgBox "ok"
Exit SubErrHandler:
' 用户按了“取消”按钮
MsgBox "取消"
Exit Sub
End Sub
CommonDialog1.FileName = gcststrOutPutScanFileName '我定以的一个文件名常量
CommonDialog1.Flags = 1
CommonDialog1.Filter = "Excel Files (*.xls)|*.xls"
On Error resume next
CommonDialog1.ShowSave
if err.number=0& then
MsgBox "ok"
elseif err.number=cdlcancel then
MsgBox "取消"
else
MsgBox "错误"
endif
on error goto 0
on error goto e
cdlSave.CancelError = true
cdlSave.FileName = gcststrOutPutScanFileName '我定以的一个文件名常量
cdlSave.Flags = ccdlOFNOverwritePrompt
cdlSave.Filter = "Excel Files (*.xls)|*.xls"
cdlSave.ShowSaveFileCopy strPath, cdlSave.FileName
e:
if err.number=32755 then exit sub
end sub