Home |
Search |
Today's Posts |
#11
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Tom,
My original problem was not knowing if an addin was currently loaded. Perhaps it was because it was the way I asked the question, but most of the answers I was getting were related to have a ticked reference in the Addin manager. In fact all this tells me is that it had been loaded at some point in time, NOT that it was currently actually loaded. For some reason in the past someone sugested that I use this code: Dim WBName As String On Error Resume Next ' turn off error checking WBName = Workbooks(DCMaster2).Name LastError = Err On Error GoTo 0 ' restore error checking If LastError < 0 Then Where the error condition would give me the answer I was looking for, but this did not work correctly. With all my digging around, the answer (that seems to work) was right under my nose, and so I have re-written the function: Function AddinPresent(DCMaster2) As Boolean Dim AddInInstalled As Boolean With AddIns.Add(FileName:=Application.UserLibraryPath & DCMaster2) ' Is Addin Installed? AddInInstalled = .Installed End With If AddInInstalled Then ' Addin is installed, exit function AddinPresent = True Exit Function Else ' Addin is NOT install, attempt to load it With AddIns.Add(FileName:=Application.UserLibraryPath & DCMaster2) .Installed = True End With ' Now check that the Addin has loaded With AddIns.Add(FileName:=Application.UserLibraryPath & DCMaster2) AddInInstalled = .Installed End With If AddInInstalled Then ' Addin is installed, exit function AddinPresent = True Exit Function Else ' Addin has failed to install AddinPresent = False Exit Function End If End If End Function Many thanks for you help and eveyone elses, hopefully this is it. -- Trefor "Tom Ogilvy" wrote: Looks like that code is checking for a reference to the addin - not sure what it has to do with the question you asked. -- Regards, Tom Ogilvy "Trefor" wrote in message ... gimme_this_gimme_that, I get an Error, "Invalid use of Me Keyword" -- 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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
addin problems | Excel Programming | |||
Problems with AddIn Installation | Excel Programming | |||
AddIn installation Problems | Excel Programming | |||
AddIn installation Problems | Excel Programming | |||
Problems with Excel Com Addin | Excel Programming |