Disable Add-Ins using VBA Excel 2003

P

powlaz

I am interested in knowing if it is possible to disable an add-in in the
workbook open event using VBA. I have just identified a problem with the
Dymo LabelWriter add-in that is causing one of my workbooks to error out.

Since we don't need the Dymo printer (or any printer) for this workbook I
would like to disable the add-in. Please tell me how I can do this. I speak
pretty poor VB so an example is much appreciated.

Thanks,

MJ
 
M

Mike H

Hi,

This would uninstall the Analysis toolpak so substiitute with you addin name

Sub UnInstall_Addins()
Dim XLAddin As AddIn
For Each XLAddin In Application.AddIns
If XLAddin.Name = "ANALYS32.XLL" = True Then
XLAddin.Installed = False
End If
Next XLAddin
End Sub

Mike
 
G

Gary Keramidas

you could put this in the workbook open event:

AddIns("addInName").Installed = False

then before close event:

AddIns("addInName").Installed = true
 
D

Dave Peterson

Maybe you could just close that addin when you open your workbook and reopen the
addin when you close your workbook???

Option Explicit
Const AddinPath As String = "c:\excel\" '<- include that trailing backslash!
Const AddinName As String = "DemoAddinNameHere.xla"
Private Sub Workbook_BeforeClose(Cancel As Boolean)

Dim TestWkbk As Workbook
Dim Resp As Long

Set TestWkbk = Nothing
On Error Resume Next
Set TestWkbk = Workbooks(AddinName)
On Error GoTo 0

If TestWkbk Is Nothing Then
Resp = MsgBox(Prompt:="Wanna open " & AddinName & "?", Buttons:=vbYesNo)
If Resp = vbYes Then
'open it
Workbooks.Open Filename:=(AddinPath & AddinName)
End If
End If

End Sub
Private Sub Workbook_Open()

On Error Resume Next
Workbooks(AddinName).Close savechanges:=False
On Error GoTo 0

End Sub

=========
If you were really industrious, you could open/close the addin when you
deactivate/activate your workbook.
 

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