Consulting

Results 1 to 9 of 9

Thread: Referring to excel application

  1. #1
    VBAX Tutor
    Joined
    Mar 2010
    Posts
    287
    Location

    Question Referring to excel application

    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.

    Me.
    Window
    Application
    A declaration?

    Trying to minimise the amount of work required.

  2. #2
    VBAX Master Aflatoon's Avatar
    Joined
    Sep 2009
    Location
    UK
    Posts
    1,720
    Location
    application
    Be as you wish to seem

  3. #3
    VBAX Tutor
    Joined
    Mar 2010
    Posts
    287
    Location
    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

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    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.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    VBAX Master Aflatoon's Avatar
    Joined
    Sep 2009
    Location
    UK
    Posts
    1,720
    Location
    I agree - typical code should not break simply because the application is not active.
    Be as you wish to seem

  6. #6
    VBAX Tutor
    Joined
    Mar 2010
    Posts
    287
    Location
    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

  7. #7
    VBAX Master Aflatoon's Avatar
    Joined
    Sep 2009
    Location
    UK
    Posts
    1,720
    Location
    Do it manually? How many are there?
    Be as you wish to seem

  8. #8
    VBAX Tutor
    Joined
    Mar 2010
    Posts
    287
    Location
    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) ?

  9. #9
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    As said, I think manually is the only sure and safe way. I am afraid you have drawn the short straw on this one.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •