PC Review


Reply
Thread Tools Rate Thread

Code to detect if add-in is available

 
 
sweez
Guest
Posts: n/a
 
      18th Mar 2008
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.
 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      18th Mar 2008
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

--
---
HTH

Bob


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



"sweez" <(E-Mail Removed)> wrote in message
news:a523690b-2e0d-49f4-9e23-(E-Mail Removed)...
>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.



 
Reply With Quote
 
Peter T
Guest
Posts: n/a
 
      18th Mar 2008
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



"sweez" <(E-Mail Removed)> wrote in message
news:a523690b-2e0d-49f4-9e23-(E-Mail Removed)...
> 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.



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem: Too many response code 404, how to detect them? Jeff Microsoft ASP .NET 5 24th Feb 2010 08:08 AM
Detect is table exists in codE? SirPoonga Microsoft Access 2 28th Feb 2005 04:07 PM
Unable to detect what is wrong with my code?! Butt Chin Chuan Microsoft Dot NET Compact Framework 3 4th Jan 2004 09:54 PM
Need code to detect grouped sheets Andy Microsoft Excel Misc 4 5th Dec 2003 01:42 AM
IE detect status code RdU Microsoft VB .NET 0 9th Jul 2003 11:08 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:57 PM.