Posts

Showing posts from October, 2005

Python script to stop Excel loading any addins on startup

Works for Excel 2000, probably adaptable to other versions of excel. You would need to check your registry to work out if your version of Excel uses the same OPEN, OPEN1 ... values to store addins to load on startup. import _winreg import os.path as path import re EXCEL_SUBKEY = r "Software\Microsoft\Office\10.0\Excel\Options" hkey = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, EXCEL_SUBKEY, 0, _winreg.KEY_ALL_ACCESS) try : (numSubKeys, numValues, lastModified) = _winreg.QueryInfoKey(hkey) valuesToDelete=[] for i in xrange(numValues): valuename, data, type =_winreg.EnumValue(hkey, i) if re.match(r 'OPEN\d*' , valuename): print "Deleting " +valuename + " : " +str(data) valuesToDelete.append(valuename) for value in valuesToDelete: _winreg.DeleteValue(hkey, value) finally : _winreg.CloseKey(hkey)