Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Mar 2001
    Location
    Ontario, Canada
    Posts
    57
    Thanks
    1
    Thanked 0 Times in 0 Posts

    error trapping dialogue boxes (2003)

    I have a macro which uses the getopenfilename dialogue. I want to be able to trap what happens if the user presses the cancel button.

    myfile = Application.GetOpenFilename("Comma Delimited files,*.csv", 1, "Ancil PS projection files", , True)
    If myfile = False Then GoTo lab2

    This works fine if the cancel button has been pressed and myfile is indeed = false. However, if the user has selected one or more files, then I get a "runtime error 13 - type mismatch on the 2nd line.

    Can someone please show me how I should be doing this. Thanks.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: error trapping dialogue boxes (2003)

    Try

    If VarType(myfile) = vbBoolean Then GoTo lab2

  3. #3
    Star Lounger
    Join Date
    Mar 2001
    Location
    Ontario, Canada
    Posts
    57
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: error trapping dialogue boxes (2003)

    Thank you very much. Worked great.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •