Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / March 2008

Tip: Looking for answers? Try searching our database.

Code to detect if add-in is available

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
sweez - 18 Mar 2008 13:41 GMT
I have the below code that I use to toggle a third-party macro from
"installed" to "uninstalled" and vice versa:

If AddIns("Hello World").installed = True Then AddIns("Hello
World").installed = False

The problem is I can not seem to come up with code that I can use to
detect if the addin is available.  So if a user does not have this
addin available the code will produce an error.  I am looking for
something like below (though I know the code is not right but it
illustrates what I would like to do).

If AddIns("Hello World").available = True Then
       If AddIns("Hello World").installed = True Then AddIns("Hello
World").installed = False
end if

Does anyone know how I might be able to do this?  Thanks in advance
for any assistance.
Bob Phillips - 18 Mar 2008 14:16 GMT
See if this works for you

Public Sub TestAddin()
Const ADDIN_NAME As String = "MyAddin.xla"
Const BASE_KEY As String = "HKCU\Software\Microsoft\Office\"
Dim WSH As Object
Dim AppVer As String
Dim RegKey As Variant
Dim i As Long

   Set WSH = CreateObject("WScript.Shell")
   AppVer = Format(Val(Application.Version), "0.0")
   On Error GoTo TestAddin_Exit
   RegKey = WSH.regread(BASE_KEY & AppVer & "\Excel\Options\OPEN")
   If RegKey Like "*" & ADDIN_NAME & "*" Then

       MsgBox "Addin available"
   Else

       Do

           i = i + 1
           RegKey = WSH.regread(BASE_KEY & AppVer & "\Excel\Options\OPEN" &
i)
           If RegKey Like "*" & ADDIN_NAME & "*" Then

               MsgBox "Addin available"
           End If
       Loop
   End If
TestAddin_Exit:
End Sub

Signature

---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

>I have the below code that I use to toggle a third-party macro from
> "installed" to "uninstalled" and vice versa:
[quoted text clipped - 15 lines]
> Does anyone know how I might be able to do this?  Thanks in advance
> for any assistance.
Peter T - 18 Mar 2008 14:36 GMT
Assuming the addin has already been installed into the addins collection

Dim adn as Addin

On error resume Next
Set adn - Addins("Hello World") ' use title
On error goto 0 ' or resume normal error handling

If adn is Nothing Then
'    maybe see if it's open, if so could 'Add' it to the addins collection
'   and Install it
Else
   ' toggle - really ?
   adn.Installed = Not adn.Installed
End If

Curiosity - why toggle

Regards,
Peter T

> I have the below code that I use to toggle a third-party macro from
> "installed" to "uninstalled" and vice versa:
[quoted text clipped - 15 lines]
> Does anyone know how I might be able to do this?  Thanks in advance
> for any assistance.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.