+ Reply to Thread
Results 1 to 9 of 9

Allow User to Choose File to Open

  1. #1
    Registered User
    Join Date
    07-30-2008
    Location
    MANCHESTER
    Posts
    30

    Allow User to Choose File to Open

    hi, i am looking to create a macro that will allow a user to select a file to open. Once the user has selected the file, I would like to copy all values in that file from Cells A to X and then copy it back to the original file.

    I have managed to get some help in writing the following code:

    Please Login or Register  to view this content.
    But this only opens the file, so i was hoping somebody could help me get a bit further.

    Thanks in advance.

  2. #2
    Registered User
    Join Date
    02-12-2008
    Location
    Portugal
    Posts
    26
    Try this code:
    Please Login or Register  to view this content.
    Last edited by Glytch; 08-06-2008 at 11:08 AM.

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Glytch,

    Please read the Forum Rules and then edit your post to wrap your code with Code Tags.

  4. #4
    Registered User
    Join Date
    02-12-2008
    Location
    Portugal
    Posts
    26
    Done.
    Sorry to fast to help that missed on that part.

  5. #5
    Registered User
    Join Date
    07-30-2008
    Location
    MANCHESTER
    Posts
    30

    File Open and Copy

    Glytch, thanks i will give that a go and let you know how i can get on. Thanks once again.

  6. #6
    Registered User
    Join Date
    07-30-2008
    Location
    MANCHESTER
    Posts
    30

    File to Close

    I have managed to use the code that was kindly written by Glytch and I have also added some code to copy the required data from the file that has been opened. The following is the code:

    Please Login or Register  to view this content.
    Where I am struggling is to close the workbook that has been opened after the data has been copied. I have added the code but this gives me a "compile error, wrong number of arguments". Could any1 please help?

    Thanks in advance.

  7. #7
    Valued Forum Contributor
    Join Date
    08-26-2006
    Location
    -
    MS-Off Ver
    2010
    Posts
    388
    I generally use object variables when using external workbooks.

    The code below declares a Workbook object and sets it to refer to the opened external workbook.
    Then the Range.Copy Method is used to do the copying.

    The code I've used for the copying is very similar to the Range.Copy Method example in Excel Help, with the addition of Workbook references.
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    07-30-2008
    Location
    MANCHESTER
    Posts
    30

    File to Close

    Thanks T-J, i will give that a go and let you know how i get on.

  9. #9
    Registered User
    Join Date
    02-12-2008
    Location
    Portugal
    Posts
    26
    If that doesnt do the the trick you can always see the attached file.

    Here you have a macro that you can copy a sheet from a closed workbook.

    Glytch
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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