PDA

View Full Version : Delete Add-in with code



Djblois
05-22-2007, 08:48 AM
I am writing an un-install option into my program and I am trying to have it delete the add-in from the users add-ins folder when they run it. This is the code I tried and it says subscript out of range:

Workbooks("C:\Documents and Settings\" & Environ("username") _
& "\Application Data\Microsoft\Addins\Business Reporting Today.xla").Delete

Is this possible?

mdmackillop
05-22-2007, 09:56 AM
Are you trying to delete the file that contains the uninstall code? I don't think you can do this.

Djblois
05-22-2007, 09:59 AM
yeah that was what I was trying. Thank you for your help.

Bob Phillips
05-22-2007, 10:01 AM
GoTo ErrorHandler
With ThisWorkbook
If .Path "" Then
.Saved = True
.ChangeFileAccess xlReadOnly
Kill ActiveWorkbook.FullName
End If
End With
Exit Sub

ErrorHandler:
MsgBox "Fail to delete file: " & ThisWorkbook.FullName
Exit Sub