+ Reply to Thread
Results 1 to 14 of 14

Export all modules dynamically to folder

  1. #1
    Forum Contributor Webbers's Avatar
    Join Date
    09-06-2005
    Location
    Poinciana, FL
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    337

    Export all modules dynamically to folder

    Is there a way to export copies of all modules from a workbook with VBA (would like to be able to run from personal workbook)? I would like to avoid having to export them individually if possible. I have searched intensely and seen multiple posts about exporting to another workbook, but I want them on my computer in the project file. Thanks in advance for any help!

    The macro would check if a folder exists ("Macros")
    • If it does, place the macros in the folder
    • Any already exist, ask before overwriting
    • If it does not, create folder then add to
    • The folder would be created on the same level as the Development folder I am working in.
    • This would all be based on the Active workbook, so no hardcoded path to constantly change

    For each report I do, the following folders exist, with excepting of the Macros on most.
    • Development Templates
    • Macros
    • Other
    • Reports - Weekly
    • Reports - Monthly
    ~*~ Sherry ~*~
    Poinciana, FL

  2. #2
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,084

    Re: Export all modules dynamically to folder

    Have a look at Ron's site here https://www.rondebruin.nl/win/s9/win002.htm

  3. #3
    Forum Contributor Webbers's Avatar
    Join Date
    09-06-2005
    Location
    Poinciana, FL
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    337

    Re: Export all modules dynamically to folder

    Fluff13,

    It seemed to be what I needed. I added it to a new module in my personal workbook. I have one workbook open, and it contains 8 modules. But I received the "Export is ready" messagebok, and nothing else happened. What did I do wrong?

  4. #4
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,084

    Re: Export all modules dynamically to folder

    Probably nothing as a default it puts the files in your documents folder in a directory called VBAProjectFiles

  5. #5
    Forum Contributor Webbers's Avatar
    Join Date
    09-06-2005
    Location
    Poinciana, FL
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    337

    Re: Export all modules dynamically to folder

    Fluff13,

    I just discovered that and was about to come tell you I found them. Can you help me modify the path (dynamically) where it will let me choose the location, and it will have a starting point of where ever my active file is? Since I work multiple projects having one master folder for all VBA modules is not something beneficial, especially as most projects have similar module names, even though the subs are not always the same (m_Save, m_Format, m_Copy for example). That would be a huge help. Thanks

  6. #6
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,084

    Re: Export all modules dynamically to folder

    In the
    Please Login or Register  to view this content.
    procedure change
    Please Login or Register  to view this content.
    to

    Please Login or Register  to view this content.
    One word of warning, it looks as though the code will delete any files already in the VBAProjectFiles directory

  7. #7
    Forum Contributor Webbers's Avatar
    Join Date
    09-06-2005
    Location
    Poinciana, FL
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    337

    Re: Export all modules dynamically to folder

    Fluff13,

    I heed your warning. I made the changes (thanks for such clear instructions). But when I ran it, I got the "Export Folder not exist" message. Now, I am confused, as when this was saving to the documents folder, if the VBAProjectFiles folder did not exist, it was created, yet now that it is in a new location, it gives me an error.

  8. #8
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,084

    Re: Export all modules dynamically to folder

    Is the active workbook on your hard drive, or somewhere else?
    It maybe you do not have the ability to create folders in that directory.

  9. #9
    Forum Contributor Webbers's Avatar
    Join Date
    09-06-2005
    Location
    Poinciana, FL
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    337

    Re: Export all modules dynamically to folder

    It is located on onedrive (i HATE onedrive). We are forced to work out of onedrive rather than from our personal hard drive. When I copy the file path (shown in the screenshot). The portions in red are changed from the actual portions of this path to their generic equivalent. This is what is displayed:

    C:\UserData\username\OneDrive - Company Name\Documents\CAPA\Incident Management v2\Reporting\KPI Reports

    The folder marked "Development - Macros" was when I manually did this, each module, one at a time.
    Attached Images Attached Images

  10. #10
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,084

    Re: Export all modules dynamically to folder

    I'm afraid I have never worked with OneDrive, so cannot help with that.

  11. #11
    Forum Contributor Webbers's Avatar
    Join Date
    09-06-2005
    Location
    Poinciana, FL
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    337

    Re: Export all modules dynamically to folder

    Fluff13,

    Okay np, I wish I wasn't forced to. What about "Plan B"... instead of defaulting to the active path, which is what I want, Is there a way for me to browse to select the location, then the VBAProjectFiles would be created there?

  12. #12
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,084

    Re: Export all modules dynamically to folder

    How about
    Please Login or Register  to view this content.

  13. #13
    Forum Contributor Webbers's Avatar
    Join Date
    09-06-2005
    Location
    Poinciana, FL
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    337

    Re: Export all modules dynamically to folder

    Fluff13,

    I tried that, and the browse dialog appeared, and it all seemed to work. But when I ran it a 2nd, 3rd, and 4th time (even on different projects), no browse dialog box appeared and it just overwrote the files (as you warned) in the previous location.

    I feel what I may need to do is to use the My Documents folder, as this script was originally written and manually move the folder to my active project. That will allow me to make sure the macros are where they should be (on OneDrive), and if there is any overwriting of files it is because I want there to be.

    As usual, Fluff13, you have been a tremendous help! Thank you so very much for all your help, it is greatly appreciated!!!!

  14. #14
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,084

    Re: Export all modules dynamically to folder

    You're welcome & thanks for the feedback.

+ 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] Arrangement of modules in a separate Module folder
    By Saturn in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-09-2019, 03:29 AM
  2. [SOLVED] How to export all the vb modules in an excel file at one shot
    By invendis in forum Excel General
    Replies: 2
    Last Post: 02-21-2017, 03:39 AM
  3. [SOLVED] Importing modules from a folder
    By michaelberrier in forum Excel General
    Replies: 0
    Last Post: 06-25-2006, 05:00 PM
  4. [SOLVED] Export modules from protected projects
    By Frederick Chow in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-16-2006, 05:10 PM
  5. Export modules from protected projects
    By Frederick Chow in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-21-2006, 01:10 PM
  6. [SOLVED] auto-export VBA modules
    By Christopher Merrill in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-20-2005, 02:05 PM
  7. Managing Modules/Macros - More than one Module FOLDER?
    By Hari Prasadh in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-30-2005, 10:05 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