Hi
I make fairly extensive use of workbook event macros such as Workbook_Open, _Activate, _SheetCalculate, _SheetChange, _SheetSelectionChange and Worksheet event macros such as Worksheet_Activate, _Change and _FollowHyperlink.
These work great except occasionally and very intermittently and most notably, Workbook_open in one of my workbooks will suddenly trigger when another workbook is opened in the same Excel instance. The problem is that my Workbook_Open macro assumes it is the active workbook, even when the workbook and worksheet.range references are fully quaified, and looks for certain values, tables, etc, which when not found produces a Debug error. I can correct this on the fly simply by making the correct workbook active and continuing the macro execution and all is well (fortunately Workbook_Open only sets up some default public variables so does not interfere with its normal operation). I can't reproduce this as it only happens every now and then. This particular workbook does include an Ontime event to run a macro every 15 minutes. My only theory is that somehow the Ontime trigger may occur at the exact time another workbook is opened which somehow precipitates the error, but even that doesn't make too much sense and it is impossible to reproduce. If I do experience this, I can correct it on the fly by simply making the right workbook the active workbook and continuing the macro execution.
My only workaround is to ensure that this workbook is open in a completely independent Excel instance by making use of the Alt-key hold when opening another workbook, a workaround I've been using successfully for almost 3-years. However, I also allow other less savvy Windows and Excel personnel use the same workbook and since it's quite difficult to explain how to use the Alt-key to start a separate instance, what to expect and what this even means, this process often falls on deaf ears. So, they tend to load up all their workbooks in a single session and the error manifests intermittently as I've explained. These people typically also don't understand the way to make the right workbook active on the desktop and continue the macro execution. FYI: All my reference to the correct workbook and any worksheet, cell, range or table within that workbook are full qualified (e.g. Workbook(file path+name).Worksheets(sheet name).range(range name), in an attempt to avoid ambiguities such as activeworkbook, activesheet, or other such default references to cell, ranges and tables. Nevertheless, the problem continues to manifest intermittently. Even my references to cells and ranges in the Workbook_Open macro!
Any ideas would be valuable.
Thanks
Max
I make fairly extensive use of workbook event macros such as Workbook_Open, _Activate, _SheetCalculate, _SheetChange, _SheetSelectionChange and Worksheet event macros such as Worksheet_Activate, _Change and _FollowHyperlink.
These work great except occasionally and very intermittently and most notably, Workbook_open in one of my workbooks will suddenly trigger when another workbook is opened in the same Excel instance. The problem is that my Workbook_Open macro assumes it is the active workbook, even when the workbook and worksheet.range references are fully quaified, and looks for certain values, tables, etc, which when not found produces a Debug error. I can correct this on the fly simply by making the correct workbook active and continuing the macro execution and all is well (fortunately Workbook_Open only sets up some default public variables so does not interfere with its normal operation). I can't reproduce this as it only happens every now and then. This particular workbook does include an Ontime event to run a macro every 15 minutes. My only theory is that somehow the Ontime trigger may occur at the exact time another workbook is opened which somehow precipitates the error, but even that doesn't make too much sense and it is impossible to reproduce. If I do experience this, I can correct it on the fly by simply making the right workbook the active workbook and continuing the macro execution.
My only workaround is to ensure that this workbook is open in a completely independent Excel instance by making use of the Alt-key hold when opening another workbook, a workaround I've been using successfully for almost 3-years. However, I also allow other less savvy Windows and Excel personnel use the same workbook and since it's quite difficult to explain how to use the Alt-key to start a separate instance, what to expect and what this even means, this process often falls on deaf ears. So, they tend to load up all their workbooks in a single session and the error manifests intermittently as I've explained. These people typically also don't understand the way to make the right workbook active on the desktop and continue the macro execution. FYI: All my reference to the correct workbook and any worksheet, cell, range or table within that workbook are full qualified (e.g. Workbook(file path+name).Worksheets(sheet name).range(range name), in an attempt to avoid ambiguities such as activeworkbook, activesheet, or other such default references to cell, ranges and tables. Nevertheless, the problem continues to manifest intermittently. Even my references to cells and ranges in the Workbook_Open macro!
Any ideas would be valuable.
Thanks
Max