Why does my VBA macro end after opening file?

Page 2 of 2 FirstFirst 12

  1. Posts : 23
    Windows 7 Home (x64)
    Thread Starter
       #11

    To copy my macros in my new PERSONAL.XLSA, I actually used NotePad as an intermediate. Bloats shouldn't have copied through there, right?
      My Computer


  2. Posts : 1,002
    XP Pro (x86) | 7 HP (x86) & (x64) | 7 Pro (x64)
       #12

    I actually used NotePad as an intermediate. Bloats shouldn't have copied through there, right?
    I assumed you were copying from a module and pasting into a new module in a new workbook.

    MSC = MS Clipboard
    I am not an expert on the finer points of MSC.
    In your case when copying from module to MSC, the previous item is cleared and stores the new item (module), maybe including stuff we dont know about. Considering MSC also copies formatting of Word data (incl formatting) -- text, images, files etc.
    But when you copied to Notepad (which results in text only) and recopied Notepad to MSC -- MSC would again clear the old item to hold the new "pure text"

    If you want to play with MSC and see just what it holds, create a shortcut to
    Code:
    C:\WINDOWS\system32\clipbrd.exe
    ... ie, clipbrd.exe not clipboard.exe
    A window that shows the current clip, and you can clear MSC from the same window.
    (Almost as exciting as watching paint dry )

    I love VBA probably because I have used it since WordBasic days. But I do acknowledge it is prone to instability. VBA has always satisfied all my needs

    Regards,
    Russell
      My Computer


  3. Posts : 1
    Windows 7 Enterprise
       #13

    Re: Why does my VBA macro end after opening file?


    Having seen this problem with one of my macros I search and came across this thread from a while ago. Although labelled 'solved' none the solutions offered were a fix for me. It was not to do with the Shift key being pressed as some suggested. I struggled with the premature macro termination issue (after command Workbooks.Open) for a whole day until I worked it out (quite pleased with myself as an amateur). I did obvserve though that the problem happened with some files that I was trying to open but not others. Then I started looking at what was different between these files. Then it struck me - it was about macros! Although most of the files contained macros, some had ones which automatically activate upon file open (macros within the ThisWorkbook object).
    Deactivating these before opening the file did the trick (using Application.EnableEvents = False). Of course you then need to re-enable them after opening the file.

    I hope this is of help to someone. :)
      My Computer


 
Page 2 of 2 FirstFirst 12

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 07:58.
Find Us