View Full Version : Referring to excel application

07-25-2012, 03:07 AM
I have a problem with a full product I have inherited (20,000 lines of code with 1,300 subs).

When using the excel product everything is fine. If I change the active window (e.g. go to outlook to check mail) then the code often falls over. This is a referencing issue.

What is the best method of referencing within excel (or a declaration) to ensure the active excel instance is always referred to by the VBA.

A declaration?

Trying to minimise the amount of work required.

07-25-2012, 03:09 AM

07-25-2012, 03:11 AM
What is the best way to fix this entire app? I think there is alot of bad coding where the application isn't specifically referred to, but don't want to declare application for every sub

07-25-2012, 03:15 AM
I don't think I ever refer to application explicitly and don't recall any problems. You need to find the offending code and fix it, which means detailed debugging I feel.

07-25-2012, 03:19 AM
I agree - typical code should not break simply because the application is not active.

07-25-2012, 03:26 AM
Perfect thanks guys. For debugging I need to unlock several VBE items. But they are all loaded as add-ins. I have the password (it's the same for all).

I have been given it in protected form, what is the quickest way to unlock ALL items in the VBE (including those loaded as addins)? For standard projects it is easy, but any loop I have seen skips over addins

07-25-2012, 03:29 AM
Do it manually? How many are there?

07-25-2012, 03:34 AM
Quite a few. I will unlock them all once and then remove security password manually - unless there is a simple loop to remove protection (once they are all unlocked) ?

07-25-2012, 11:03 AM
As said, I think manually is the only sure and safe way. I am afraid you have drawn the short straw on this one.