+ Reply to Thread
Results 1 to 8 of 8

How to export code from a text editor in the main workbook to a text editor for many files

  1. #1
    Registered User
    Join Date
    02-24-2018
    Location
    Canada
    MS-Off Ver
    2007
    Posts
    97

    How to export code from a text editor in the main workbook to a text editor for many files

    Hello everyone
    I have searched in this wonderful Forum and found this file
    I need help in just one point
    How can add a line in the same code to export the codes in Module NO 2 to the text editor In all the files that have been created
    Hope it is clear
    Thanks advanced for help
    Attached Files Attached Files
    Last edited by Feisty2; 04-19-2018 at 08:34 PM.

  2. #2
    Registered User
    Join Date
    02-24-2018
    Location
    Canada
    MS-Off Ver
    2007
    Posts
    97

    Re: How to export code from a text editor in the main workbook to a text editor for many f

    Is it possible to achieve that?

  3. #3
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: How to export code from a text editor in the main workbook to a text editor for many f

    If I understood you well: Yes, it is.

    First of all you shall SaveAs with fileformat 52 not 51
    51 is xlOpenXMLWorkbook (without macro's in 2007-2016, xlsx)
    52 is xlOpenXMLWorkbookMacroEnabled (with [or without] macro's in 2007-2016, xlsm)
    Second you have to enable VBA access to Project Object model. Two actions are needed:
    * VB Editor > Tools > References > (Check) Microsoft Visual Basic for Applications Extensibility 5.3
    * File -> Options -> Trust Center -> Trust Center Setttings -> Macro Settings -> Trust Access to the VBA Project object model.

    And having these requirements completed, you could use code similar to the one from here: https://stackoverflow.com/questions/...other-workbook to write module into the file
    Best Regards,

    Kaper

  4. #4
    Registered User
    Join Date
    02-24-2018
    Location
    Canada
    MS-Off Ver
    2007
    Posts
    97

    Re: How to export code from a text editor in the main workbook to a text editor for many f

    Thanks a lot Mr.Kaper for your reply and take your time
    Yes, I'm sure you understand what I want
    I have make sure to follow the above procedures
    and I tried to understand the codes on the the above link. and do it myself but it seems that I'm just a beginner
    Hope you would help me in this topic
    Best and kind regards

  5. #5
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: How to export code from a text editor in the main workbook to a text editor for many f

    If you successfully changed Trust Access to VBA model and marked reference as checked, then code part in your Module1 is as follows:

    Please Login or Register  to view this content.
    See also attached file - I tested it and it prepares set of 8 new xlsm files with Module2 inside.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    02-24-2018
    Location
    Canada
    MS-Off Ver
    2007
    Posts
    97

    Re: How to export code from a text editor in the main workbook to a text editor for many f

    Thank you very very much Mr. Kaper for this perfect solution That's great and exactly what I was searching for
    It's my great pleasure to know a person like you
    Can I ask for another point ..
    How can to run all the codes In all the files that have been created
    Is there any additional lines should I add?
    Best and kind regards

  7. #7
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: How to export code from a text editor in the main workbook to a text editor for many f

    The issue with files created before is that these files are in xlsx format (not enabled macros). So these files shall be first converted into xlsm format, possibly with adding a module to each of them.

    Here is example procedure to do it (copy it into your module 1 (and remember to make a backup copy of original xlsx files in case something goes wrong during this conversion):
    Please Login or Register  to view this content.
    And after running this, your files will be xlsm type and will contain all Module2 code inside

  8. #8
    Registered User
    Join Date
    02-24-2018
    Location
    Canada
    MS-Off Ver
    2007
    Posts
    97

    Re: How to export code from a text editor in the main workbook to a text editor for many f

    Thank you very much Mr. Kaper for this useful information. I appreciate that a lot
    I can't express my happiness with this perfect and great solution ..You are life savior
    Best Regards from the deep of my heart

+ 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. Export data from the main sheet to many open files
    By Joky in forum Excel Programming / VBA / Macros
    Replies: 42
    Last Post: 02-09-2018, 11:57 PM
  2. [SOLVED] adjustment in vba properties editor for sheet tabs and merging of codes
    By JEAN1972 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-25-2017, 10:53 AM
  3. Need advice: Change VBA codes on worksheet without opening VBA Editor
    By Danny2312 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-01-2017, 11:38 AM
  4. Export worksheets in a workbook to seperate files keeping Column C hidden
    By Sgligori in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-07-2015, 01:30 PM
  5. Replies: 0
    Last Post: 07-12-2012, 12:31 PM
  6. Excel VBA row export to multiple text files
    By warren13 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-11-2011, 03:02 AM
  7. Editing Excel files in text editor (vim)
    By odicenta in forum Excel General
    Replies: 3
    Last Post: 01-19-2009, 12:25 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