+ Reply to Thread
Results 1 to 5 of 5

end if cancel clicked on .FileDialog(msoFileDialogFolderPicker).Show

  1. #1
    Forum Contributor
    Join Date
    03-22-2016
    Location
    Philippines
    MS-Off Ver
    MS Office 2013
    Posts
    124

    Question end if cancel clicked on .FileDialog(msoFileDialogFolderPicker).Show

    having trouble ending a macro when the user clicks cancel on the select folder path dialog box that opens when they run the macro .FileDialog(msoFileDialogFolderPicker).Show returns false when you click cancel and have msgbox "nothing selected", but I can't get any further than that.



    Please Login or Register  to view this content.
    Thanks!
    Last edited by dedark05; 09-21-2016 at 09:38 PM.

  2. #2
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Re: end if cancel clicked on .FileDialog(msoFileDialogFolderPicker).Show

    Good morning dedark05

    Don't use the FileDialog command - use the GetopenFileName instruction instead, This allows you more control, and allows you to intercept the routine when the Cancel button has been clicked.

    The self contained example below shows how it works, and how to provide feedback when cancelled.

    Please Login or Register  to view this content.
    HTH

    DominicB

  3. #3
    Forum Contributor
    Join Date
    03-22-2016
    Location
    Philippines
    MS-Off Ver
    MS Office 2013
    Posts
    124

    Re: end if cancel clicked on .FileDialog(msoFileDialogFolderPicker).Show

    Hi there dominicb, Good evening from here in the Philippines

    Thank you for helping. I'm new to VBA so please bare with me. This code is from the different people who helped me made this. I really don't know how to apply that method to my existing code.

    so please check my actual file for you to test it.
    https://www.dropbox.com/s/59l70ai311...v0.6.xlsm?dl=0

    It's the "Select Data Source Folder Path" button.

  4. #4
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Re: end if cancel clicked on .FileDialog(msoFileDialogFolderPicker).Show

    Hi dedark05

    You know when you start answering a thread without properly reading the question ...

    Please Login or Register  to view this content.
    The code had the bones of handling the errors there - I've just finished it off.

    HTH

    DominicB

  5. #5
    Forum Contributor
    Join Date
    03-22-2016
    Location
    Philippines
    MS-Off Ver
    MS Office 2013
    Posts
    124

    Re: end if cancel clicked on .FileDialog(msoFileDialogFolderPicker).Show

    Good morning dominicb,

    It works! I didn't expect that only Exit Sub and Msgbox was added. Thanks you so much! I will now mark this thread as solved.

    Just a few more question, how can I change ".FileDialog(msoFileDialogFolderPicker).Show" function to ".FileDialog(msoFileDialogFilePicker).Show"? I really can't make it work. I would like to select a file (.txt file) directly instead of selecting a the folder path of that file.

    here is the thread
    http://www.excelforum.com/showthread...t=#post4485383

    I already edited it based on your code here and with some modification.

+ 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. Show Files in Folder using Application.FileDialog(msoFileDialogFolderPicker)
    By rtcwlomax in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-05-2015, 09:53 AM
  2. [SOLVED] Exit Sub when Cancel is clicked on Input Box
    By rtcwlomax in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-09-2015, 01:57 PM
  3. [SOLVED] InputBox User Clicked Cancel
    By goss in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-05-2014, 03:19 PM
  4. VBA to show excel files inside a folder Application.FileDialog(msoFileDialogFolderPicker)
    By Paul Cherian in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-03-2014, 08:17 AM
  5. [SOLVED] GetOpenFile Crashes upon cancel being clicked
    By AdamManning in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-21-2014, 07:09 AM
  6. Replies: 1
    Last Post: 07-11-2013, 05:01 PM
  7. [SOLVED] FileDialog(msoFileDialogFolderPicker) not using the current direct
    By nx3 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-08-2006, 08:25 AM

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