Consulting

Results 1 to 4 of 4

Thread: Delete Add-in with code

  1. #1
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,091
    Location

    Delete Add-in with code

    I am writing an un-install option into my program and I am trying to have it delete the add-in from the users add-ins folder when they run it. This is the code I tried and it says subscript out of range:

    [VBA]Workbooks("C:\Documents and Settings\" & Environ("username") _
    & "\Application Data\Microsoft\Addins\Business Reporting Today.xla").Delete[/VBA]

    Is this possible?

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Are you trying to delete the file that contains the uninstall code? I don't think you can do this.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,091
    Location
    yeah that was what I was trying. Thank you for your help.

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    GoTo ErrorHandler
    With ThisWorkbook
    If .Path "" Then
    .Saved = True
    .ChangeFileAccess xlReadOnly
    Kill ActiveWorkbook.FullName
    End If
    End With
    Exit Sub

    ErrorHandler:
    MsgBox "Fail to delete file: " & ThisWorkbook.FullName
    Exit Sub

    [/vba]

Posting Permissions

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