I have built an Add-In which is intended to be downloaded from the www. The Add-In will land up in the user computer's Downloads folder.
On being activated, the first phase of the Add-In's activty is to copy itself into the user's '/Microsoft/AddIns' folder using SaveAs. Then then "parent" Add-in closes itself and quits Excel. (On restarting Excel the "child" Add-In will be loaded and active.)
The code for this is
Sub CheckInstall()
'Several lines of code before this.
'They have been tested and seem to work well.
MyNewfileNm = TestBase & GCSAPPNAME
If IsInstalled(MyNewfileNm) Then
Application.DisplayAlerts = False
ThisWorkBook.SaveCopyAs MyNewfileNm
Application.DisplayAlerts = True
MsgBox "We're done, and Excel will close." & Chr(13) & _
"On reopening you will find 'ACBA Mapping' loaded and active in the ADD-INS tab."
Excel.Application.Quit
ActiveWorkbook.Close False
Else
ThisWorkBook.SaveCopyAs MyNewfileNm
If ActiveWorkbook Is Nothing Then
Workbooks.Add
Set oAddIn = Application.AddIns.Add(MyNewfileNm, False)
oAddIn.Installed = True
Else
Set oAddIn = Application.AddIns.Add(MyNewfileNm, False)
oAddIn.Installed = True
End If
MsgBox "We're done, and Excel will close." & Chr(13) & _
"On reopening you will find 'ACBA Mapping' loaded and active in the ADD-INS tab."
Excel.Application.Quit
ActiveWorkbook.Close False
End If
End Sub
This processes and copies itself as expected, but before the Application.Quit completes I get an Error Code 91. On clicking the error message, it simply resumes the instruction code.The result is precisely as expected.
However, I must either solve the problem generating the error message or suppress the error message. For the time being I cannot do either.
I'd be grateful for a solution.