uninstall-add in

F

filo666

Hi, I'm trying to figure out how to accomplish somehting:

I have an add-in and I would like it to chek the computer's name when
installed, if the computer's name does not match the default registered
computer's name (Leon1 in this case) then the add-in is uninstalled
(uninstall itself).
The code works fine until the AddIns("Periodical Table").Install=false is
called:


Private Sub Workbook_AddinInstall()
strComputer = "."
Set objWMIService = GetObject("winmgmts:" &
"{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\cimv2")
Set colSettings = objWMIService.ExecQuery("Select * from
Win32_ComputerSystem")
With Workbooks("periodical Table.xla").Sheets(2)
For Each objComputer In colSettings
If LCase(objComputer.Name) <> "leon1" Then
MsgBox "The program has detected that you coppied the add-in, please contact
your program provider", vbOKOnly, "Illegal copy detection"
AddIns("Periodical Table").Install=false
Else: GoTo nx
End If
Next
End With
nx:
End Sub


It does not appear any error, the msgbox works well but it nevers uninstall
the add-in.

TIA
 
J

Jim Cone

See your earlier post.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"filo666"
wrote in message
Hi, I'm trying to figure out how to accomplish somehting:
I have an add-in and I would like it to chek the computer's name when
installed, if the computer's name does not match the default registered
computer's name (Leon1 in this case) then the add-in is uninstalled
(uninstall itself).
The code works fine until the AddIns("Periodical Table").Install=false is
called:

Private Sub Workbook_AddinInstall()
strComputer = "."
Set objWMIService = GetObject("winmgmts:" &
"{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\cimv2")
Set colSettings = objWMIService.ExecQuery("Select * from
Win32_ComputerSystem")
With Workbooks("periodical Table.xla").Sheets(2)
For Each objComputer In colSettings
If LCase(objComputer.Name) <> "leon1" Then
MsgBox "The program has detected that you coppied the add-in, please contact
your program provider", vbOKOnly, "Illegal copy detection"
AddIns("Periodical Table").Install=false
Else: GoTo nx
End If
Next
End With
nx:
End Sub

It does not appear any error, the msgbox works well but it nevers uninstall
the add-in.
TIA
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top