Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Code to detect if add-in is available

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Code to detect if add-in is available

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" wrote in message
...
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.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Code to detect if add-in is available

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" wrote in message
...
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to detect symbol/special character code Jeff Ingman Excel Discussion (Misc queries) 19 September 26th 07 08:41 PM
How to detect #N/A and return 0? Eric Excel Discussion (Misc queries) 2 May 30th 07 06:12 AM
Detect Cell Changes aga2957[_5_] Excel Programming 4 August 21st 06 06:03 AM
To detect changes in a worksheet Sinus Log Excel Programming 4 December 8th 05 07:43 AM
how to detect paste mjb267 Excel Programming 3 April 6th 04 07:54 PM


All times are GMT +1. The time now is 08:27 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"