none
Visual Basic Editor Code Window Changes when different Workbook activated RRS feed

  • Question

  • Using MS Office 2016 and Windows 10.

    When I am writing a procedure in VBA using the VBE and I open a new workbook or change the active workbook, the VBE code window usually (but not always) changes to a procedure in the newly activated workbook.  This can be very annoying when I have activated a different workbook in order to check a reference in that workbook, but wish to continue writing code in the original.   I cannot find any obvious ways in Tools | Options or elsewhere to prevent this.  Does anyone know of a way of leaving the current VBE code window displayed when the active workbook is changed?


    Tuesday, February 28, 2017 11:27 AM

Answers

  • Hi AndyColRomsey,

    I try to reproduce the issue as per your instructions mentioned in your last post.

    I am able to reproduce this behavior successfully on my side.

    and it's looks like it is the default behavior of VBE, that whenever you try to open any .xlsm file then VBE window will change to latest file window.

    there is no solution available for this behavior.

    if you think that , this behavior should be get changed in the newer versions of Excel then please try to submit your feedback to user voice.

    Excel User Voice

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, March 2, 2017 6:21 AM
    Moderator

All replies

  • Hi AndyColRomsey,

    as per your description I try to test this on my side, I find that when I open or change the new workbook then VBE code window is not get changed to new active workbook.

    it stays as it is , so I can start to write code from there directly, no need to change anything.

    it looks like something get corrupted with in your MS Office.

    I suggest you to update your MS Office with latest available updates may solve your issue.

    if you are not able to update then you can try to repair your MS Office may solve your issue.

    if that also not help you to solve the issue then try to reinstall the MS Office may solve your issue.

    try to implement above mentioned suggestions to solve this issue.

    let us know about your testing results.

    if still problem not solved then we will try to suggest you further to solve this issue.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, March 1, 2017 2:12 AM
    Moderator
  • Deepak

    Thanks for looking at this.  I have now checked this behaviour on three computers, the other two running Office 2007 on Vista / Windows 7, and it happens on all of them.  It seems that the change of the VBE code window only occurs if the newly opened workbook is macro enabled (.xlsm), which is logical I suppose.  It seems to change the code window to an arbitrary module in the newly opened workbook.  Certainly it is not the one which was active when the workbook was last saved.  Some of the workbooks that induce the change have workbook open events, but not all of them.  I have not been able to find any consistency in the case where I simply change the active workbook;  sometimes it changes the code window, sometimes not.

    It may be that this is simply a feature of the VBE, in which case I will just live with it.

    Andy C

    Wednesday, March 1, 2017 12:06 PM
  • Hi AndyColRomsey,

    I try to reproduce the issue as per your instructions mentioned in your last post.

    I am able to reproduce this behavior successfully on my side.

    and it's looks like it is the default behavior of VBE, that whenever you try to open any .xlsm file then VBE window will change to latest file window.

    there is no solution available for this behavior.

    if you think that , this behavior should be get changed in the newer versions of Excel then please try to submit your feedback to user voice.

    Excel User Voice

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, March 2, 2017 6:21 AM
    Moderator
  • Deepak

    Thanks for your reply.  I have, as you suggested, submitted the appropriate feedback.

    Andy C

    Thursday, March 2, 2017 10:40 AM
  • Hi AndyColRomsey,

    Now , we know that this is not a bug and its the by default behavior of Excel VBE.

    so I think from that your doubt is clear now.

    this thread is still open, I suggest you to mark the answer.

    so that we can close this thread.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, March 3, 2017 6:55 AM
    Moderator