+ Reply to Thread
Results 1 to 4 of 4

Cancel Addin Install from Workbook_AddinInstall?

Hybrid View

  1. #1
    Dave Ramage
    Guest

    Cancel Addin Install from Workbook_AddinInstall?

    Hello,

    Can anyone tell me if/how it is possible to cancel the installation of an
    addin from either Workbook_Open or Workbook_AddinInstall?

    I want to prevent users from installing an addin file if it located on a
    network drive. The problem is that once the user has started the installation
    process (either by double clicking the file in explorer or through
    Tools/Iddins), it seems difficult to stop by VBA code!

    This is what I've tried so far:

    Private Sub Workbook_AddinInstall()
    Dim a As AddIn
    If OnNetworkDrive(Thisworkbook.FullName) Then 'returns true if file is on
    network drive
    Thisworkbook.Close
    For Each a In Application.AddIns
    If a.Name = ThisWorkbook.Name Then
    a.Installed = False
    End If
    Next a
    Exit Sub
    End If
    'goes on to install menus etc.
    End Sub

    This closes the addin workbook OK, but does not prevent the addin being
    installed- i.e. next time Excel is started, the add-in is loaded.

    Thanks,
    Dave



  2. #2
    Ivan Raiminius
    Guest

    Re: Cancel Addin Install from Workbook_AddinInstall?

    Hi Dave,

    this should help:

    Private Sub Workbook_AddinInstall()
    Dim a As AddIn
    If OnNetworkDrive(Thisworkbook.FullName) Then 'returns true if file
    is on
    network drive
    For Each a In Application.AddIns
    If a.Name = ThisWorkbook.Name Then
    a.Installed = False
    End If
    Next a
    Thisworkbook.Close
    Exit Sub
    End If
    'goes on to install menus etc.
    End Sub

    Whend Workbook_addininstall event occurs, the addin is already
    installed, so you have to uninstall it first and then you may close the
    workbook.

    Regards,
    Ivan


  3. #3
    Dave Ramage
    Guest

    Re: Cancel Addin Install from Workbook_AddinInstall?

    Ivan,

    Thanks for the suggestion, but have tried this and it doesn't work. The
    ..Installed property of the Addin in question is actually False anyway, so the
    line:
    a.Installed = False
    doesn't actually change anything

    Cheers,
    Dave

    "Ivan Raiminius" wrote:

    > Hi Dave,
    >
    > this should help:
    >
    > Private Sub Workbook_AddinInstall()
    > Dim a As AddIn
    > If OnNetworkDrive(Thisworkbook.FullName) Then 'returns true if file
    > is on
    > network drive
    > For Each a In Application.AddIns
    > If a.Name = ThisWorkbook.Name Then
    > a.Installed = False
    > End If
    > Next a
    > Thisworkbook.Close
    > Exit Sub
    > End If
    > 'goes on to install menus etc.
    > End Sub
    >
    > Whend Workbook_addininstall event occurs, the addin is already
    > installed, so you have to uninstall it first and then you may close the
    > workbook.
    >
    > Regards,
    > Ivan
    >
    >


  4. #4
    Peter T
    Guest

    Re: Cancel Addin Install from Workbook_AddinInstall?

    Hi Dave,

    Need to bear in mind that the AddinInstall event fires before the addin
    actually gets installed. So let that pass then uninstall after, eg

    Private Sub Workbook_AddinInstall()

    'If some condition that disallows install then

    Application.OnTime Now, "UninstallMe"

    'End if
    End Sub

    ' in a normal module

    Sub UninstallMe()
    MsgBox "Don't install me agian ! " _
    & ThisWorkbook.Name, , "Bye"

    Application.AddIns(ThisWorkbook.Title).Installed = False

    End Sub

    ..Title requires your title in Properties > Summary > Title
    Alternatively loop through the collection looking for thisworkbook.name

    The addin will close and not load next time. Though not installed it may
    remain in the addins collection, conveniently waiting for user to tick it
    again without having to Browse to. Could be a little or lot more work to get
    rid of all trace of it.

    Regards,
    Peter T

    "Dave Ramage" <DaveRamage@discussions.microsoft.com> wrote in message
    news:81AEBCF0-EE39-4765-A31D-36EBAC3C44E0@microsoft.com...
    > Hello,
    >
    > Can anyone tell me if/how it is possible to cancel the installation of an
    > addin from either Workbook_Open or Workbook_AddinInstall?
    >
    > I want to prevent users from installing an addin file if it located on a
    > network drive. The problem is that once the user has started the

    installation
    > process (either by double clicking the file in explorer or through
    > Tools/Iddins), it seems difficult to stop by VBA code!
    >
    > This is what I've tried so far:
    >
    > Private Sub Workbook_AddinInstall()
    > Dim a As AddIn
    > If OnNetworkDrive(Thisworkbook.FullName) Then 'returns true if file is

    on
    > network drive
    > Thisworkbook.Close
    > For Each a In Application.AddIns
    > If a.Name = ThisWorkbook.Name Then
    > a.Installed = False
    > End If
    > Next a
    > Exit Sub
    > End If
    > 'goes on to install menus etc.
    > End Sub
    >
    > This closes the addin workbook OK, but does not prevent the addin being
    > installed- i.e. next time Excel is started, the add-in is loaded.
    >
    > Thanks,
    > Dave
    >
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1