View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Trefor Trefor is offline
external usenet poster
 
Posts: 201
Default Problems checking for an Addin

gimme_this_gimme_that,

Thankyou for your reply. Please see my reply to Tom re what I am trying to
do here. I need to think about what you have sent me to see if it helps, so
thankyou for now.
--
Trefor


" wrote:

This might be useful to you.

A means to check if a reference exists from a template and a method to
remove the reference later so others can read the Workbook you created
from the Template and the AddIn.


Put these Subs into the Template:

Private Sub Workbook_Open()
If ReferenceExists("MyAddInName") Then
' call StartUpSub in the NameOfAddInModule
NameOfAddInModule.StartUpSub Me
End If
End Sub

Private Function ReferenceExists(reference As String) As Boolean
Dim result As Boolean
result = False

On Error Resume Next
result = Not Me.VBProject.References(reference) Is Nothing

ReferenceExists = result
End Function


Then in the Template call this:


Public Sub RemoveReferences(book As Workbook)
book.VBProject.References.Remove
book.VBProject.References("MyAddInName")
End Sub