Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-08-2014, 06:26 PM
chrismad chrismad is offline Removing add in programatically Windows 7 64bit Removing add in programatically Office 2013
Novice
Removing add in programatically
 
Join Date: Apr 2014
Posts: 5
chrismad is on a distinguished road
Default Removing add in programatically

Hi,



I need to remove an add in (global template) programatically.

I uncheck and remove the add in from the list as follows:
Code:
Application.AddIns(sAddInFileName).Installed = False
Application.AddIns(sAddInFileName).Delete
However, when trying to delete the actual file in the Startup folder via
Code:
Kill sAddInFilenameAndPath
I run into error # 70 "Permission denied".

Hence, I assume the template file is still open but when trying to use
Code:
Documents(sAddInFilenameOnly).Close
before the kill command, I get error # 4160 "Bad file name". Yet, sAddInFilenameOnly holds the proper string.

Thanks for your help.
Reply With Quote
  #2  
Old 05-08-2014, 08:25 PM
macropod's Avatar
macropod macropod is offline Removing add in programatically Windows 7 32bit Removing add in programatically Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Can you delete the addin manually after running:
Code:
Application.AddIns(sAddInFileName).Installed = False
Application.AddIns(sAddInFileName).Delete
If so, the file isn't open.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 05-08-2014, 10:03 PM
chrismad chrismad is offline Removing add in programatically Windows 7 64bit Removing add in programatically Office 2013
Novice
Removing add in programatically
 
Join Date: Apr 2014
Posts: 5
chrismad is on a distinguished road
Default

Thanks. That got me a step further. The template is indeed open.

For testing purposes I commented out the disabling and removal from the global template list. Then I inserted the following code:

Code:
MsgBox Templates.Count
MsgBox Templates.Item(sOldAddInFile).FullName

For Each oTemp In Application.Templates
    sMsg = oTemp.FullName & vbNewLine
Next oTemp
MsgBox sMsg
Templates.Count tells me there are 2 templates open. Those would my add in and Normal.dot. The 2nd line properly spits out path & name of my add in file. So it does exist and everything seems fine.

Then, however, when I iterate through the templates collection, the msgbox only lists the Normal.dot as entry and not my add in file. Weird! Any clue why or how that could be?

Yet, even if I solve that issue, unlike the documents collection, the templates collection does not have a close method. So, the question would still be, how can I close the add-in file?

Unfortunately, the add-in is not part of the documents collection. I checked!

Help is much appreciated.
Reply With Quote
  #4  
Old 05-08-2014, 10:47 PM
macropod's Avatar
macropod macropod is offline Removing add in programatically Windows 7 32bit Removing add in programatically Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

This works for me:
Code:
Sub KillMyAddin(sAddInFileName As String)
Dim strFile As String, oAddIn As AddIn
For Each oAddIn In Application.AddIns
  With oAddIn
    If .Name = sAddInFileName Then
      strFile = .Path & "\" & sAddInFileName
      .Installed = False
      .Delete
      End If
      Kill strFile
  End With
Next
End Sub
One thing to note though is that, if the Addin is also the attached template, you'd have to detach it (e.g. ActiveDocument.AttachedTemplate = "") before you could delete it.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 05-14-2014, 02:56 PM
chrismad chrismad is offline Removing add in programatically Windows 7 64bit Removing add in programatically Office 2013
Novice
Removing add in programatically
 
Join Date: Apr 2014
Posts: 5
chrismad is on a distinguished road
Default

Though I don't see any major differences, your scripts worked.
Thank you.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Removing add in programatically Programatically hide slides during presentation ky1488 PowerPoint 4 09-11-2013 08:21 AM
How do I send an email programatically? macroscope Outlook 7 02-01-2013 02:27 PM
Removing add in programatically Programatically Managing Word Document Structure mlbliss Word VBA 3 11-07-2012 07:42 PM
Removing add in programatically Apply font color programatically using VBA Word divakarganta Word VBA 3 08-08-2012 08:05 PM
Programatically open Outlook folder (set focus) using RDO? NicMic Outlook 0 01-10-2008 03:27 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:30 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft