+ Reply to Thread
Results 1 to 11 of 11

Overwrite Thisworkbook code with Macro

  1. #1
    Registered User
    Join Date
    05-07-2013
    Location
    Amsterdam
    MS-Off Ver
    Excel 2013
    Posts
    72

    Overwrite Thisworkbook code with Macro

    hi,

    i have 350 workbooks with all different modules. But also codes in "Thisworkbook" (workbook_open and workbook_beforeClose)

    Now I forgot to put in "Application.ScreenUpdating = False" Means everytime people open the excel workbook you everything flickering due to its macro.

    I need to update those workbooks by Macro anyway and I want to include that code (Application.ScreenUpdating = False) into all the "Thisworkbook"

    Now can I do this? Can I overwrite the entire code or do can I just add that piece of text?

    Thanks!
    Last edited by Fean; 05-07-2013 at 04:04 AM. Reason: typo

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Overwrite Thisworkbook code with Macro

    See http://www.cpearson.com/excel/vbe.aspx

  3. #3
    Registered User
    Join Date
    05-07-2013
    Location
    Amsterdam
    MS-Off Ver
    Excel 2013
    Posts
    72

    Re: Overwrite Thisworkbook code with Macro

    Quote Originally Posted by cytop View Post
    i have seen that site and also Ron de Bruin site and even more, i have googled a lot on this topic. But I don't know how to put this all together.. I guess i need to use vbext_ct_Document
    But there isnt any easier way of basically,
    Please Login or Register  to view this content.
    etc. or insert line.?
    Last edited by arlu1201; 05-07-2013 at 06:15 AM. Reason: Use code tags in future.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Overwrite Thisworkbook code with Macro

    This code will add Application.ScreenUpdating = False at the start of Workbook_Open.
    Please Login or Register  to view this content.
    As it is the code is using ActiveWorkbook, what you need is further code to loop through your workbooks, open them, run this code on them and then saving.

    What that code is really depends on if you have a list of the workbooks and their locations, they all reside in the same directory or have a common name - basically something to find them.
    If posting code please use code tags, see here.

  5. #5
    Registered User
    Join Date
    05-07-2013
    Location
    Amsterdam
    MS-Off Ver
    Excel 2013
    Posts
    72

    Re: Overwrite Thisworkbook code with Macro

    Quote Originally Posted by Norie View Post
    This code will add Application.ScreenUpdating = False at the start of Workbook_Open.
    Please Login or Register  to view this content.
    As it is the code is using ActiveWorkbook, what you need is further code to loop through your workbooks, open them, run this code on them and then saving.

    What that code is really depends on if you have a list of the workbooks and their locations, they all reside in the same directory or have a common name - basically something to find them.
    That is working! Some piece of work this is. I don't understand it fully but indeed I took the code within the loop.. and it placed the code into the thisworkbook!
    Although its 1 line above the Workbook_Open. It should go in the the Workbook_open..

    Please Login or Register  to view this content.
    Last edited by Fean; 05-16-2013 at 04:00 AM. Reason: typo

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    If that's what's happening then the code isn't working.

    I tested it on workbooks that only had code for the Open event.

  7. #7
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Overwrite Thisworkbook code with Macro

    perhaps use
    Please Login or Register  to view this content.
    rather than
    Please Login or Register  to view this content.
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  8. #8
    Registered User
    Join Date
    05-07-2013
    Location
    Amsterdam
    MS-Off Ver
    Excel 2013
    Posts
    72

    Re: Overwrite Thisworkbook code with Macro

    Quote Originally Posted by JosephP View Post
    perhaps use
    Please Login or Register  to view this content.
    rather than
    Please Login or Register  to view this content.
    Tested that, it gets me a Runtime on . deleteLines ?
    Please Login or Register  to view this content.

  9. #9
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Overwrite Thisworkbook code with Macro

    perhaps just
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    05-07-2013
    Location
    Amsterdam
    MS-Off Ver
    Excel 2013
    Posts
    72

    Re: Overwrite Thisworkbook code with Macro

    Spot on! That worked well! Such relieve this, this really helped me out.

    Many thanks for you help!!

  11. #11
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Overwrite Thisworkbook code with Macro

    you're welcome :-)

    don't forget to mark the thread solved

+ 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