|
Sub Regsvrs() '以下以注册VBAniGIF.OCX控件为例
Set FSO = CreateObject("Scripting.FileSystemObject")
f = ThisWorkbook.Path & "\VBAniGIF.OCX" '控件文件夹/控件名称
x = FSO.FolderExists("C:\Windows\syswow64")
If x Then '判断windows系统是64位还是32位
t = "C:\Windows\syswow64\VBAniGIF.OCX"
Else: t = "C:\Windows\system32\VBAniGIF.OCX"
End If
Set sa = CreateObject("Shell.Application") '以管理员身份运行cmd
sa.ShellExecute "cmd", " /c Copy """ & f & """, """ & t & """", , "runas", 1
sa.ShellExecute "cmd", " /c Regsvr32 /s " & t, , "runas", 1
MsgBox "AniGif控件已成功注册,现在可以使用了!"
End Sub |
|