+ Reply to Thread
Results 1 to 9 of 9

Open file from a folder and assign that file to an Object variable

  1. #1
    Registered User
    Join Date
    06-20-2012
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    15

    Open file from a folder and assign that file to an Object variable

    Hi all!!

    I need a code in Excel vba to open a folder, select a file from that folder and assign that file to a variable (obj1 As Object type)


    Please help!!

    Thanks in Advance
    Last edited by pratyu; 06-22-2012 at 02:52 AM.

  2. #2
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Open file from a folder and assign that file to an Object variable

    Try this,

    Please Login or Register  to view this content.
    Be fore warned, I regularly post drunk. So don't take offence (too much) to what I say.
    I am the real 'Napster'
    The Grid. A digital frontier. I tried to picture clusters of information as they moved through the computer. What did they look like? Ships? motorcycles? Were the circuits like freeways? I kept dreaming of a world I thought I'd never see. And then, one day...

    If you receive help please give thanks. Click the * in the bottom left hand corner.

    snb's VBA Help Files

  3. #3
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Open file from a folder and assign that file to an Object variable

    To expand a little on Dave's suggestion:
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    06-20-2012
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Open file from a folder and assign that file to an Object variable

    Thanks to Dave & Kyle for the quick replies.
    But, I have a different problem...

    The code should give an option to SELECT ANY file from a folder and assign it to a variable of Object type....


    Sorry for the ambiguity in my thread.!

    Please help!

  5. #5
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Open file from a folder and assign that file to an Object variable

    Maybe the msoFilepicker,

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    06-20-2012
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Open file from a folder and assign that file to an Object variable

    Hi Dave!!

    This code is working but somehow the files aren't shown in the folder!!

    Any other thing to be added?

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Open file from a folder and assign that file to an Object variable

    Try this

    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  8. #8
    Registered User
    Join Date
    06-20-2012
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Open file from a folder and assign that file to an Object variable

    I've mistyped the file extension name...
    I've corrected that and it worked...!! Thanks a lot!!

  9. #9
    Registered User
    Join Date
    06-20-2012
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Open file from a folder and assign that file to an Object variable

    Thanks a lot royUK... it worked!!

+ 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