Consulting

Results 1 to 16 of 16

Thread: How to remove (Delete) a Word global template add-in from the Add-ins list?

  1. #1
    VBAX Regular
    Joined
    Mar 2011
    Posts
    64
    Location

    How to remove (Delete) a Word global template add-in from the Add-ins list?

    How can I programmatically delete a single add-in? I don't want to deactivate it (uncheck it), I want to delete it completely. I know the specific name, say "MyTemplate.dotm".

    I found the following code posted that supposedly deletes all deactivated add-ins, but what would be the syntax for a specific template?

    Private Sub  Delete_UnInstalled_WordAddins()
    Dim oAddin As AddIn
    On Error GoTo Err_Addin
    For Each oAddin In AddIns
     If oAddin.Installed = False Then
     oAddin.Delete
     End If
     Next oAddin
    Finally:
     If Not oAddin Is Nothing Then Set oAddin =  Nothing
    Err_Addin:
     If Err <  > 0 Then
     Err.Clear
     GoTo Finally
     End  If
    End  Sub

  2. #2
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,272
    Location
    You need to know the path:
    AddIns( _
    "FullPath\MyTemplate.dotm" _
    ).Delete
    Greg

    Visit my website: http://gregmaxey.com

  3. #3
    VBAX Regular
    Joined
    Mar 2011
    Posts
    64
    Location
    Thanks for the reply, Greg.

    Will that actually delete the .dotm file itself, or just remove the add-in from the Add-ins list in Word? I only want the latter result.

  4. #4
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    It just removes it from the Addins collection.

  5. #5
    VBAX Regular
    Joined
    Mar 2011
    Posts
    64
    Location
    I tried the syntax Greg posted and it moved the add-in from the 'Active Application Add-ins' list to the 'Inactive' list. That's better, but any way to make it vanish from the lists altogether? BTW, it also appears in the 'Global templates and add-ins' list preceded by an unchecked checkbox. I would like for it not to appear in this list at all.

    Thanks for the info.

  6. #6
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    You do not actually need to know the path. You can pick that up programmatically.
    Sub RemoveUnusedAddin()
    Dim oAddin As AddIn
    For Each oAddin In AddIns
       If oAddin.Installed = False Then
          AddIns(oAddin.Path & "\" & oAddin.Name).Delete
       End If
    Next
    End Sub

  7. #7
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    The above completely removes all inactive addins from the list. Or at least it does for me.

  8. #8
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,272
    Location
    Well, I only tested with one that "appears in the 'Global templates and add-ins' list preceded by an unchecked checkbox" and it deleted it from that list. Maybe you have to run the code twice?
    Greg

    Visit my website: http://gregmaxey.com

  9. #9
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    I tested with six addins on the list.

    Three checked.
    Three unchecked.

    The code (executed only once) completely removed the unchecked addins from the list.

  10. #10
    VBAX Regular
    Joined
    Mar 2011
    Posts
    64
    Location
    This info has helped a lot. Still getting some mixed results, though. To explain further:
    I've been using autoexec in a template (Template1.dotm) in local \startup folder to load 2 other global templates (Template2.dotm/Template3.dotm) that are located on a remote server. Since Template1 is only used to load the other 2 add-ins, I wish to remove it from the add-in list after it serves its purpose. I don't want it to cause confusion, etc.

    First, to "uncheck" it in the add-ins list I used:
    AddIns("Template1.dotm").Installed = False[/vba]
    Then, I used fumei's code to remove it from the add-ins list:
    [vba] Dim oAddin As AddIn 
    For Each oAddin In AddIns 
    If oAddin.Installed = False Then 
    AddIns(oAddin.Path & "\" & oAddin.Name).Delete 
    End If 
    Next
    The steps above moved the add-in from the 'Active Application Add-ins' list to the 'Inactive' list. It still appears in the 'Global templates and add-ins' list preceded by an unchecked checkbox.

    I tried running code twice, no difference. Ideally, I'd like the add-in to vanish from all lists.

  11. #11
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    Ah, you did not mention they were in Startup. I never put global addins in Startup.

    No, sorry, because Startup loads them (i.e. puts them in the list) when Word starts up (duh), they remain on the list for that session of Word. And since if you stop that session and start Word up again you load them again, you are stuck. They are on the list. You can uncheck them, but not remove them. The Remove button is greyed out, yes?

    It is for this reason that we had a VERY small global addin in staff Startup that did ONE thing...dynamically load/unload the real addins from a network folder (i.e. NOT Startup).

    I do not think there is a way around this for you. They are loaded from Startup and persist for that session of Word.

    This is why I do not put addins in Startup. They remain.

  12. #12
    VBAX Regular
    Joined
    Mar 2011
    Posts
    64
    Location
    Okay, that explains it then. It's not the end of the world, but I was hoping for a cleaner load up.

    Thanks very much for the nifty code.

  13. #13
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    May I ask why this was important? You were concerned users could activate the addins? What would be the negative of that?

    If there IS a serious negative, then I suggest you consider having them loaded dynamically, rather than through Startup. From a systems perspective it is better:

    1. the basic wee addin IN Startup only does one thing, and so there is little (or none) maintenance required;
    2. the working addins can be left on a network drive(not the users) which makes them more secure as they can be used by users, but the files themselves can be denied access;
    3. the working addins, by remaining on the network, are not affected by any altered circumstances on any individual machine, thus making maintenance, testing and error correction of the addins greatly simplified.

  14. #14
    VBAX Regular
    Joined
    Mar 2011
    Posts
    64
    Location
    My desire to have the add-in removed from the add-ins list is nothing too important or critical, just I think it will be cleaner, that's all. For instance, if a user goes to the list and sees the unchecked add-in (that's actually not doing anything after it serves its purpose), it may result in a help desk call or something. Just cleaner to have it removed from the list, out of sight, out of mind, you know.

    As I mentioned in a post above, the add-in in the startup folder is a very small .dotm that has no other purpose than to load 2 other global add-ins from a secure location on a remote network server. This method is set up essentially as you describe above. The add-ins on the server are more easily updated/maintained that way.

    Not sure what you mean by "loaded dynamically". Definitely interested, though.

  15. #15
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    "the add-in in the startup folder is a very small .dotm that has no other purpose than to load 2 other global add-ins from a secure location on a remote network server. This method is set up essentially as you describe above. The add-ins on the server are more easily updated/maintained that way."

    That is precisely why. So does the wee one load the others automatically? It seems so.

    By dynamically, I mean that ours added a toolbar icon which had:

    Finance
    Personnel
    Engineering

    and others.

    That way, the Finance people got the Finance addins, Personnel got the theirs, Engineering got theirs.

    It was a toggle. Click again, it was removed.

  16. #16
    Okay, propably too late for you, but this helped me and might help others:
    Quote Originally Posted by DaVinney View Post
    The steps above moved the add-in from the 'Active Application Add-ins' list to the 'Inactive' list. It still appears in the 'Global templates and add-ins' list preceded by an unchecked checkbox.

    I tried running code twice, no difference. Ideally, I'd like the add-in to vanish from all lists.
    You can ".Installed=False" the AddIn, you can ".Delete" the AddIn (as you mentioned) and - tadaaa! - you can delete the file using "Kill(oAddin.Name)". That will physically remove it for the entire outside world. BUT you will still see it in the AddIns-list until you close Word, and you can not use FileCopy or anything to recreate it, as Word thinks this AddIn is still there until you close Word.

Posting Permissions

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