Macros Cause Closed Files To Open

  • To test this situation I made a copy of a 'File1' and saved it as 'File2', where File1 had many macros that ran within the file (none required the use of any other files). The problem comes when I open File1 and File2 and then close File2.
    Then when I try to run a macro in File1 it just opens File2 even though I did not copy anything from File2 into File1 or make any changes whatsoever.

    This was an experiment I tried to do to narrow the problem, as of now I know its not because of copied text. This problem arrived when I tried to copy information from a different file into 'File1' and when I closed the other file, and tried to run a macro in File1, it would open the old file I copied from.

    Also, I found that to fix this problem I had to close both files and reopen them. However the macro file is quite large and takes time to save changes in and it can get frustrating when you are required to close everything after a simple copy and paste operation, just to get it to work.

    Can someone help me with this as it is crucial to the project im working on.


  • Re: Macros Cause Closed Files To Open

    Wouldn't really know where to begin without seeing some of the code in question.

    Is it invoking another workbook's macros by opening it? If so, do this:

    application.enableevents = false
    ' code
    application.enableevents = true

    Have you tried stepping through the code (pressing F8 repeatedly while in the macro, keeping the VBE at half-screen so that you can see the code and its effect on the worksheet)? This should then show at what point it's occurring.

  • Re: Macros Cause Closed Files To Open

    nvm i got it, it was because I had made both files initiate macros on the right click, and this was done in Auto_open. Therefore teh second file opened would always require teh macros and thus when it was closed and the right click was clicked, it would require teh old file and open it.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!