I have a workbook that when open will scan for a specific addin, if it's already opened, it will not reopen it, but if it isn't, it will open it. First it will scan the application.vbe.vbprojects for the unregistered addin. If i open the workbook by itself it works fine, if i have a blank workbook open first then i open the workbook that will open the addin, i get a error:
Private Sub Workbook_Open()
Dim vbproj As Object
Dim theName As String
Dim flag as Boolean
For Each vbproj In Application.VBE.VBProjects
theName = GetFilenameFromPath(vbproj.filename) <<--- Run-time error '76'" Path not found
If theName = "AddIn.xlam" Then
Flag = True
Exit For
End If
Next vbproj
If Flag = False Then
Workbooks.Open ("C:\AddIn.xlam"), , True
Workbooks("AddIn.xlam").IsAddin = True
End If
End Sub
Function GetFilenameFromPath(ByVal strPath As String) As String
If Right$(strPath, 1) <> "\" And Len(strPath) > 0 Then
GetFilenameFromPath = GetFilenameFromPath(Left$(strPath, Len(strPath) - 1)) + Right$(strPath, 1)
End If
End Function