+ Reply to Thread
Results 1 to 6 of 6

Browse for a file and embed it in a userform to open in the future

  1. #1
    Forum Contributor
    Join Date
    06-07-2014
    Posts
    213

    Browse for a file and embed it in a userform to open in the future

    Hi folks,

    It's time for the question that has been puzzling Excel VBA userform mankind for ages.

    How can one browse for a file and embed it in a userform to open in the future? The file could be a Word, PDF, jpeg or Excel file, whereby one clicks a button, browses for a file, selects and click ok and the file is embedded in a userform and can be accessed and reopened in the future. Is there any method out there that can achieve or closely achieve this?

    Thanks!

  2. #2
    Forum Contributor lancer102rus's Avatar
    Join Date
    04-02-2014
    Location
    Ufa
    MS-Off Ver
    Excel 2010, 2013
    Posts
    252

    Re: Browse for a file and embed it in a userform to open in the future

    store full path to your files in the hidden sheet and open them at any time you want
    Last edited by lancer102rus; 08-12-2014 at 11:07 PM.

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Browse for a file and embed it in a userform to open in the future

    Hello chin67326,

    I just completed a project where I needed my UserForm to remember user selections without using a separate file or worksheet.

    There are 3 parts to the process. Each embedded value is declared twice: Once as a Variable and again as a Constant. The third piece is a function that modifies the macro code for the constant declaration using the VBIDE.

    During the UserForm_Initialize() Event, the Variable is set to the Constant value. Each time the Variable is changed, the function to modify the Constant needs to called to save it for next time.

    I will work on creating a workbook to do what you want and post it in this thread for you. I should be able to finish it tonight.


    Function to Change a Constant value in the Macro Module's Code
    In my case, this macro function changes the constants in the same module the function is in.
    1. Be sure to add the Keyword "Public" before your constants.
    2. Change the name in blue to the name of your module.
    3. This function accepts both String and Long type constants.

    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Browse for a file and embed it in a userform to open in the future

    Hello chin67326,

    I just completed a project where I needed my UserForm to remember user selections without using a separate file or worksheet.

    There are 3 parts to the process. Each embedded value is declared twice: Once as a Variable and again as a Constant. The third piece is a function that modifies the macro code for the constant declaration using the VBIDE.

    During the UserForm_Initialize() Event, the Variable is set to the Constant value. Each time the Variable is changed, the function to modify the Constant needs to called to save it for next time.

    I will work on creating a workbook to do what you want and post it in this thread for you. I should be able to finish it tonight.


    Function to Change a Constant value in the Macro Module's Code
    In my case, this macro function changes the constants in the same module the function is in.
    1. Be sure to add the Keyword "Public" before your constants.
    2. Change the name in blue to the name of your module.
    3. This function accepts both String and Long type constants.

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    06-07-2014
    Posts
    213

    Re: Browse for a file and embed it in a userform to open in the future

    Thanks a lot Mr Ross; I look forward to seeing the workbook. I am excited!

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Browse for a file and embed it in a userform to open in the future

    Hello chin67326,

    Here is the workbook as promised. Let me know what you think about it.
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    06-07-2014
    Posts
    213

    Re: Browse for a file and embed it in a userform to open in the future

    Hi Leith,

    First of all I want to thank you for this and second of all, GREAT JOB!!!! Do you think there is an opportunity for this to be developed further to perhaps be able to browse and add more files to a list box for example? Or perhaps one can use several occurrences of the instance if he wants to embed several files? Get some sleep as I don't want you going off to work on this further idea, but it could be a future project. Either way, this is awesome with what I have in mind and I will focus on integrating it into a project I am working on. I appreciate it; good job and thanks!

+ 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. Get VBA to allow user to Browse for a file to open
    By JungleJme in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-28-2012, 05:52 AM
  2. Browse for File to open
    By RobynC in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-17-2007, 07:30 AM
  3. FIle Open/Browse on Macintosh
    By TooTall in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-31-2005, 03:05 PM
  4. File Browse Function (Open dialog box for choosing file)
    By b-123 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-25-2005, 06:05 PM
  5. Browse and attach file in a UserForm
    By Jeroen Kluytmans in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-07-2005, 06:06 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