Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Removing Add-ins programmatically from Excel 2003 using VBScript

This happens installing and uninstalling Add-In in Excel via VBA/vbscript:

Installing:
======
1) When you add an Add-In via VBA/VBScript using 'Application.AddIns.Add
<file, CopyFile := True' and the source file is on a local drive, the Add-In
is linked to Excel but not copied.

2) When you add an Add-In via VBA/VBScript using 'Application.AddIns.Add
<file, CopyFile := True' and the source file is *NOT* on a local drive, the
Add-In is linked to Excel after being copied to the
'%AppData%\Microsoft\AddIns' folder

In both cases you end up with an entry called "OPEN" (evt. followed by a
number) under "HKCU\Software\Microsoft\Office\<Version\Excel\Op tions" that
contains:
a) the full path for 1)
b) only the name of the file for 2)

Uninstalling:
======
The only way to uninstall via VBA/VBScript is using
'Application.AddIns(<ref).Installed = False'. However, the file remains
'visible' to Excel.

1) If the source file was *NOT* copied, the Add-In entry "OPEN" under
"HKCU\Software\Microsoft\Office\<Version\Excel\Op tions" is removed and
another one is created under
"HKCU\Software\Microsoft\Office\<Version\Excel\Ad d-in Manager" but having,
as a registry value, the full name of the file (for instance "C:\My
Folder\MyAddIn.xla")

2) If the source file was copied to the 'AppData' folder, the Add-In entry
"OPEN" under "HKCU\Software\Microsoft\Office\<Version\Excel\Op tions" is
removed. *NO* extra entry is created under
"HKCU\Software\Microsoft\Office\<Version\Excel\Ad d-in Manager"

Removing the Add-In
======
1) The file needs to be 'unRegistered'. Since 'Wscript.Shell' object cannot
handle the backslash '\' character, the only way to remove it is by using WMI
statements

Const HKEY_CURRENT_USER = &H80000001
ExcelRegistryKey = "Software\Microsoft\Office\<Version\Excel\Add-in Manager"
Set WmiRegistry = GetObject("winmgmts:\\.\root\default:StdRegProv")
Result = WmiRegistry.DeleteValue(HKEY_CURRENT_USER, ExcelRegistryKey, "C:\My
Folder\MyAddIn.xla")

The file does not have to be removed physically. Excel will not find it
anymore.

2) The file must be physically removed from the 'AppData' folder; this can
be done with the '.DeleteFile' method of a 'FileSystemObject'.

Hope this helps
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Subtotals Deleting Rows after removing Subtotal - 2003 Excel Raul[_2_] Excel Worksheet Functions 1 October 2nd 07 06:28 PM
Removing custom toolbar from Excel 2003 [email protected] Excel Discussion (Misc queries) 0 July 14th 06 05:00 PM
Using Excel 2003 SP1 - Removing a VBA module closes Excel Greg on DBear Excel Programming 0 May 30th 05 12:04 PM
Programmatically inserting a row with Excel 2003 stonequest Excel Programming 4 May 3rd 04 11:58 AM
Removing Checkboxes Programmatically Mark D'Agosta Excel Programming 4 October 21st 03 03:57 PM


All times are GMT +1. The time now is 10:39 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"