Results 1 to 9 of 9
  1. #1
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    Terneuzen, Netherlands
    Posts
    895
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I thought I could test if a particular AddIn was installed like this:

    If AddIns("test").Installed then
    MSGBox "AddIn: 'Test' is installed"
    EndIf

    I get a Subscript-out-of-range...

    I know I can do it by checking the names of all the installed AddIns vs the one I'm looking for but why isn't this one working???

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts
    Quote Originally Posted by ErikJan View Post
    Code:
    If AddIns("test").Installed then
       MSGBox "AddIn: 'Test' is installed"
    EndIf
    In Word, I get "the requested member of the collection does not exist" when I use a name that does not exist. Note that you should use the full name of the document or template as the index. (Inspect the object's .Name property to see how VBA sees it.)

  3. #3
    5 Star Lounger
    Join Date
    Aug 2004
    Location
    Connecticut, USA
    Posts
    816
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I tested with only the name (no extensions) in Excel and the only one that did not give a Subscript error was one that I had installed. All of Microsofts' Add-Ins, such as Solver gave me the error.

  4. #4
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    Terneuzen, Netherlands
    Posts
    895
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by jscher2000 View Post
    In Word, I get "the requested member of the collection does not exist" when I use a name that does not exist. Note that you should use the full name of the document or template as the index. (Inspect the object's .Name property to see how VBA sees it.)
    Strange isn't it... I'd expect that the "AddIns("Something").Installed" would simply return FALSE if the mentioned AddIn is not installed (which would happen also if we get the name wrong)...

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Similar problems have come up in the past. The only consistent workaround appears to be to loop through all add-ins, and to check the name and other properties within the loop. I don't think we found a satisfactory explanation of the cause of the problem.

  6. #6
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Or use code like:

    Code:
    Function AddInIsOpen(sAddinname As String) As Boolean
        Dim oAddin As AddIn
        On Error Resume Next
        Set oAddin = AddIns(sAddinname)
        If oAddin Is Nothing Then
            AddInIsOpen = False
        Else
            AddInIsOpen = True
        End If
    End Function
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  7. #7
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts
    Quote Originally Posted by pieterse View Post
    Or use code like:
    Is it necessary to return to normal error handling (On Error Goto 0) before leaving the Function, or does it return to normal by default when the calling procedure resumes? I think I would take the more conservative course and reset it manually even if that isn't technically necessary.

  8. #8
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts
    Afaik, On Error Resume Next only has scope within the procedure in which it exists.
    This from VBA Help seems to say that as well:

    On Error GoTo 0 disables error handling in the current procedure. .... Without an On Error GoTo 0 statement, an error handler is automatically disabled when a procedure is exited.
    Gary

  9. #9
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Gary is right, it *should* be set to goto 0 when the sub is exited, but to be on the safe side you might add the line at the end of the function.
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

Posting Permissions

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