damoruso
asked on
Excel workbook referencing error: VBA VB
Hi,
I have two macros in excel vba. One reference the other to crate dynamic menus (i.e.: the macro that creates the menu has permission for access to VBA Project). We intermittently get the message "This workbook is currently referenced by another workbook and cannot be closed when excel is started. Once it occurs, it stays.
I have included "On error resume next" and "applications.displayalert s = false" code in auto_open in both macros. All seems fine until windows performs an update. I do not know if the update has anything to do with this , but it seems to possibly have some correlation.
I can resolve the issue by re-establishing the reference between the macros. However the macros are deployed as packages to customers in large enterprises and therefore that manual solution is not feasible..
Any idea as to how to prevent this message from showing -- permantly?
Thanks
I have two macros in excel vba. One reference the other to crate dynamic menus (i.e.: the macro that creates the menu has permission for access to VBA Project). We intermittently get the message "This workbook is currently referenced by another workbook and cannot be closed when excel is started. Once it occurs, it stays.
I have included "On error resume next" and "applications.displayalert
I can resolve the issue by re-establishing the reference between the macros. However the macros are deployed as packages to customers in large enterprises and therefore that manual solution is not feasible..
Any idea as to how to prevent this message from showing -- permantly?
Thanks
ASKER
This occurs when Excek opens (even if no macros run).
The reason why they are separate is that main macro is password protected and the dynamic menu generator macro doesn't run if it protected. So we extracted the snippet of code that generates the menu and put it into a separate unprotected macro. The main macro refers to the menu generator. BTW: the dynamic menu code generates VBA on the fly and accesses VBA Project.
If there is a way that the menu code can work from within the password protected main macro, that would be ideal.
The reason why they are separate is that main macro is password protected and the dynamic menu generator macro doesn't run if it protected. So we extracted the snippet of code that generates the menu and put it into a separate unprotected macro. The main macro refers to the menu generator. BTW: the dynamic menu code generates VBA on the fly and accesses VBA Project.
If there is a way that the menu code can work from within the password protected main macro, that would be ideal.
I would use a table driven approach to generate the menu. Search the web for "table driven commandbar excel" and you should find examples. I think John Walkenbach has an example somewhere on his site.
ASKER
Sorry. I mis-wrote. These are actually forms that are being generated, not menus.
You don't have to actually generate a form in the VBA project, you can also populate an existing userform object with controls at runtime. That way, you also do not need to allow access to the VBProject. It does require you to use a class module to catch the events of the controls which were added at runtime however.
ASKER
That would be great. So I will be able to dynamically add rows of textboxes and checkbox controls based on the amount of data I have?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This looks good. I'm going through it now. It seems as though udDataEntry is of most interest for me. I'll keep you posted. Thanks!
ASKER
Great. Thanks!
(which -because it is referenced by another workbook open in Excel- causes the warning message to occur).
You could work around it, but the method depends on your code: why the reference?