+ Reply to Thread
Results 1 to 12 of 12

(Solved) Close the selected file after getting the data

  1. #1
    Registered User
    Join Date
    06-22-2015
    Location
    Malaysia
    MS-Off Ver
    2013
    Posts
    17

    (Solved) Close the selected file after getting the data

    Hi All,

    I am trying to let the users of my excel file to browse and select a file that they wanted to get the data.

    After getting the data, I wish to let the file that the user selected to close automatically.

    How can I do this with my current macro?

    Thanks!



    Please Login or Register  to view this content.
    Last edited by Allmaths; 07-01-2015 at 09:15 PM.

  2. #2
    Valued Forum Contributor Parth007's Avatar
    Join Date
    12-01-2014
    Location
    Banglore
    MS-Off Ver
    2010
    Posts
    879

    Re: Close the selected file after getting the data

    hey AllMaths,

    Try this

    Please Login or Register  to view this content.
    Regards
    Parth

    I appreciate your feedback. Hit * if u Like.
    Rules - http://www.excelforum.com/forum-rule...rum-rules.html

  3. #3
    Registered User
    Join Date
    06-22-2015
    Location
    Malaysia
    MS-Off Ver
    2013
    Posts
    17

    Re: Close the selected file after getting the data

    Quote Originally Posted by Parth007 View Post
    hey AllMaths,

    Try this

    Please Login or Register  to view this content.

    Hi Parth007,

    Thank you very much for your reply. I've tried your code, but it ends up my Excel is corrupting (Not responding I mean).

    Not sure why. My Excel version is 2013.

    Note: I am still new to VBA.

  4. #4
    Valued Forum Contributor Parth007's Avatar
    Join Date
    12-01-2014
    Location
    Banglore
    MS-Off Ver
    2010
    Posts
    879

    Re: Close the selected file after getting the data




  5. #5
    Registered User
    Join Date
    06-22-2015
    Location
    Malaysia
    MS-Off Ver
    2013
    Posts
    17

    Re: Close the selected file after getting the data

    Quote Originally Posted by Parth007 View Post


    Hi Parth007,

    Finally I get to run the macro modified by you.

    The question is the macro is shutting down my current file (Where I want this file to be opened), but not shutting down the selected browsed file (I want to close this file).

    Any idea?

    Thanks.

  6. #6
    Valued Forum Contributor Parth007's Avatar
    Join Date
    12-01-2014
    Location
    Banglore
    MS-Off Ver
    2010
    Posts
    879

    Re: Close the selected file after getting the data

    Hi AllMaths,

    Can you provide your sample file.. which file you need to close whats the name of file which is already openend previous to the current browsed file.. sharing sample file would really help

  7. #7
    Registered User
    Join Date
    06-22-2015
    Location
    Malaysia
    MS-Off Ver
    2013
    Posts
    17

    Re: Close the selected file after getting the data

    Quote Originally Posted by Parth007 View Post
    Hi AllMaths,

    Can you provide your sample file.. which file you need to close whats the name of file which is already openend previous to the current browsed file.. sharing sample file would really help

    Hi Parth007,

    There you go, I've modify the macro to match the example file.

    Thanks.
    Attached Files Attached Files

  8. #8
    Valued Forum Contributor Parth007's Avatar
    Join Date
    12-01-2014
    Location
    Banglore
    MS-Off Ver
    2010
    Posts
    879

    Re: Close the selected file after getting the data

    Please Login or Register  to view this content.
    Try this


    OPen The file & Click the button to proceed..
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    06-22-2015
    Location
    Malaysia
    MS-Off Ver
    2013
    Posts
    17

    Re: Close the selected file after getting the data

    Quote Originally Posted by Parth007 View Post
    Please Login or Register  to view this content.
    Try this


    OPen The file & Click the button to proceed..

    Hi Parth007,

    Thank you for your reply.

    The code is working, but it doesn't get me the things I really want.

    Below code is using the assumption that the user only have one and only one file to retrieve the data, which the file name is "Want to close this.xlsm".

    I wish that the macro can close the selected file, for example: "File1.xlsm", "Potato.xlsm", "Sales June.xlsm" etc.

    Because the user can select the file that they wanted to retrieve the data.

    Anyway, thank you very much for your efforts. Really appreciate it.

    If you have any better idea, feel free to share.

    Please Login or Register  to view this content.

  10. #10
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Close the selected file after getting the data

    All you need to close the workbook is this as wb refers to the workbook that's been opened.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  11. #11
    Registered User
    Join Date
    06-22-2015
    Location
    Malaysia
    MS-Off Ver
    2013
    Posts
    17

    Re: Close the selected file after getting the data

    Quote Originally Posted by Norie View Post
    All you need to close the workbook is this as wb refers to the workbook that's been opened.
    Please Login or Register  to view this content.
    Hi Norie,

    Thank you very much! This line fits my code very well!

    Didn't know just such a simple step can get all the things done!

    Thanks!

  12. #12
    Valued Forum Contributor Parth007's Avatar
    Join Date
    12-01-2014
    Location
    Banglore
    MS-Off Ver
    2010
    Posts
    879

    Re: Close the selected file after getting the data

    Grt Thanks Norie for code addition.. that completes the macro...

    Hey Allmaths.. please mark thread closed

+ 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] VBA Prompt to close PDF so file can be overwrtitten or close automatically
    By bdouglas1011 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-21-2014, 12:31 PM
  2. VBA open file, insert data, close file by tab.
    By Aquabat in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-27-2013, 03:37 PM
  3. [SOLVED] MACRO: Store name of selected file as string w/ import data file dialog box
    By AnnieMcken in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-13-2013, 02:13 PM
  4. VBA to open a file, update/refresh all data and close file?
    By brianjluke in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-29-2013, 02:27 PM
  5. How to: Open file, format data, save file, close file and repeat.
    By thexeber in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-11-2010, 12:56 PM

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