T
Trefor
I use the below code to check for an AddIn, the problem I have is the line
marked * sometimes causes an if the file is missing, but sometime the error
code is ZERO, even though the file is not installed.
I have not quite worked out what is going on, but this line seems to be
inconsistant in its result.
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
' the add-in workbook isn't currently open. Manually open it.
On Error Resume Next
Application.DisplayAlerts = False
With AddIns.Add(FileName:=Application.UserLibraryPath & DCMaster2)
.Installed = False
End With
With AddIns.Add(FileName:=Application.UserLibraryPath & DCMaster2)
.Installed = True
End With
Application.DisplayAlerts = True
LastError = Err
On Error GoTo 0 ' restore error checking
If LastError <> 0 Then
' The workbook was not found in the correct location
AddinPresent = False
Else
' The workbook was found and installed
AddinPresent = True
End If
Else
' No error so the workbook is already loaded
AddinPresent = True
End If
End Function
marked * sometimes causes an if the file is missing, but sometime the error
code is ZERO, even though the file is not installed.
I have not quite worked out what is going on, but this line seems to be
inconsistant in its result.
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
' the add-in workbook isn't currently open. Manually open it.
On Error Resume Next
Application.DisplayAlerts = False
With AddIns.Add(FileName:=Application.UserLibraryPath & DCMaster2)
.Installed = False
End With
With AddIns.Add(FileName:=Application.UserLibraryPath & DCMaster2)
.Installed = True
End With
Application.DisplayAlerts = True
LastError = Err
On Error GoTo 0 ' restore error checking
If LastError <> 0 Then
' The workbook was not found in the correct location
AddinPresent = False
Else
' The workbook was found and installed
AddinPresent = True
End If
Else
' No error so the workbook is already loaded
AddinPresent = True
End If
End Function