+ Reply to Thread
Results 1 to 2 of 2

Need EXIT/Cancel Function for Application.GetOpenFileName

  1. #1
    Registered User
    Join Date
    04-08-2015
    Location
    Merica
    MS-Off Ver
    2010
    Posts
    7

    Exclamation Need EXIT/Cancel Function for Application.GetOpenFileName

    Hello everyone, I need some assistance with some VBA code I'm working on.

    Some background on this:
    The below code works fine, so long as you DO select any number of photos above zero when the filepicker dialog pops up. If you hit Cancel, or the "X" button, it then gives 'Run-Time Error '13': Type Mismatch'.

    I have tried several Exit functions for the Application.GetOpenFileName, none have so far worked, I keep getting the Type Mismatch error.
    I DO understand I am missing a cancel checker argument, as stated, I have tried several, but they have all failed, so I am posting the code without one of those tests, in hopes someone can tell me what I'm doing wrong here.
    Because at this point, I have no idea where to put a cancel button arguement checker, and I need some help!

    Again, the code works for what I want it to do, and I can't use any MSO, or FileDialogs, I have to use the OpenFileName as a workaround for various reasons, but I need it to not result in an ERROR if Cancel is or "X" is clicked.

    Please Login or Register  to view this content.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Need EXIT/Cancel Function for Application.GetOpenFileName

    fpathArray will be False if the user exits without selecting a file, but if you test it for False and it's really an array you get a type mismatch error.

    I also recommend you explicitly declare fpathArray. I strongly recommend to everyone that they declare variables. Doing so prevents a lot of bugs and runtime errors.

    I succeeded with this:

    Please Login or Register  to view this content.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Obscure VBA error? Application.Run conflicts with Application.GetOpenFileName
    By mc84excel in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-15-2013, 08:31 PM
  2. Cancel button with GetOpenFilename()
    By Impartial Derivative in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-26-2011, 11:36 AM
  3. Re-enable sheet protection when cancel button is selected from getopenfilename window
    By DFragnDragn in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-23-2010, 12:41 AM
  4. If cancel Application.GetOpenFilename() statement
    By tapapad in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-21-2008, 02:13 PM
  5. Exit Sub when I hit cancel
    By erock24 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-20-2007, 01:27 PM
  6. Cancel an application exit from VBA?
    By helmekki in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-27-2005, 10:31 PM
  7. [SOLVED] [SOLVED] Application.GetOpenFilename vs Application.Dialogs(xlDialogsOpen)
    By Paul Martin in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-05-2005, 12:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1