你好:
請參考附件
主程式會移除 Addin 項目,並且刪除檔案
Declare Function SHFileOperation Lib "shell32.dll" Alias _
"SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
Type SHFILEOPSTRUCT
hwnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAnyOperationsAborted As Boolean
hNameMappings As Long
lpszProgressTitle As String
End Type
Sub KillAddinFile(txt As String)
With AddIns
.Item(txt).Installed = False
If Dir(.Item(txt).FullName) <> "" Then
RecycleFile (.Item(txt).FullName)
End If
SendKeys "{HOME}"
For I = 1 To .Count
If .Item(I).Title = txt Then
SendKeys "%y"
End If
SendKeys "{DOWN}"
Next I
End With
SendKeys "~{ESC}"
Application.CommandBars.FindControl(ID:=943).Execute
End Sub
Sub RecycleFile(sFile As String)
Dim FileOperation As SHFILEOPSTRUCT
Dim lReturn As Long
Dim sFileName As String
Const FO_DELETE = &H3
Const FOF_ALLOWUNDO = &H40
Const FOF_NOCONFIRMATION = &H10
With FileOperation
.wFunc = FO_DELETE
.pFrom = sFile
.fFlags = FOF_ALLOWUNDO + FOF_NOCONFIRMATION
End With
lReturn = SHFileOperation(FileOperation)
End Sub
Sub Formshow()
ReAddinForm.Show
End Sub
|