Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21090

[RESOLVED] Common dialog error trapping not working

$
0
0
I've been through a lot of "fixes" for this but nothing works. When I run this code and the user presses cancel, I get a dialog box that tells me cancel was pressed and it stops on the .showsave line. Clicking help shows the list of all error constants but no trapping seems to work.

Code:

Dim SourceFile As String

On err GoTo CancelError

SourceFile = App.Path & "\Rentals.mdb"

    With CommonDialog
        .FileName = SourceFile
        .Filter = "MDB Files(*.mdb)|*.mdb|All Files(*.*)|*.*"
        .CancelError = True
        .ShowSave
    End With
   
    CopyFileEvenIfOpen SourceFile, Me.CommonDialog.FileName

Exit Sub

CancelError:
stop
err.Clear
Exit Sub

The CopyFileEvenIfOpen subroutine uses an API call but the sub never gets that far if the commondialog is cancelled or closed so I won't put the code in here - besides it works perfectly if the user clicks save. I just get the dialog box telling me cancel was pressed and I can debug (.showsave highlighted) or end. I don't see the problem with this code ... what am I doing wrong?

TIA,
Ken

Viewing all articles
Browse latest Browse all 21090

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>