Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Word has a disabled add-ins function (Help | About | Disabled Items).

How do I add an add-in to the disabled list without having to crash the add-in and wait for the error to come up?

share|improve this question

migrated from serverfault.com Aug 3 '09 at 11:39

This question came from our site for professional system and network administrators.

    
Which version of word? –  Sam Aug 3 '09 at 10:06
    
2003, but the technique I was putting up works in 2007 and XP/2002 as well, not in 2000, though. Sorry, I should have put up in the question that I already knew the answer but wanted to put it up as it doesn't appear to be documented anywhere on the net. –  Richard Gadsden Aug 3 '09 at 10:19
    
Hmm, I considered asking this on superuser and decided that serverfault was more appropriate as it was a case where there's an easy resolution (Sam's) for a single-user environment, but I'm on a Citrix server and I need to disable for one user and not the whole server (hence my complicated registry hack). –  Richard Gadsden Aug 3 '09 at 12:10

4 Answers 4

up vote 3 down vote accepted

I was trying to figure out the binary format of the values in the DisabledItems key myself and your post here got me on the right track. I however think the format is a bit different from how you see it, at least in Office 2010.

As far as I can tell the format is like this:

  • The first four bytes are a 32-bit integer. It usually seems to have the value 1. I'm not sure what purpose it has.

  • The next four bytes are a 32-bit integer that tells us the length of the dll path in bytes, including the terminating character (null or 0x0000).

  • The next four bytes are a 32-bit integer that tells us the length of the friendly name in bytes, including the terminating character (null or 0x0000).

  • The next sequence of bytes is a null-terminated big-endian unicode string containing the path to the add-in dll. For some reason this path always seems to contain only lowercase characters.

  • The next sequence of bytes is a null-terminated big-endian unicode string containing the friendly name of the add-in.

I've been able to successfully hard-disable an add-in using the following C# code:

string path = "<full path to add-in dll>".ToLower();
string friendlyName = "<add-in friendly name>";

MemoryStream stream = new MemoryStream();
BinaryWriter writer = new BinaryWriter(stream);
writer.Write(1); // Unknown
writer.Write((path.Length * 2) + 2); // Path length, 2 bytes per character
writer.Write((friendlyName.Length * 2) + 2); // Friendly name length
writer.Write(Encoding.Unicode.GetBytes(path)); // Path
writer.Write(Convert.ToInt16(0)); // null terminator
writer.Write(Encoding.Unicode.GetBytes(friendlyName)); // Friendly name
writer.Write(Convert.ToInt16(0)); // null terminator
writer.Close();

// Version numbers: 11.0 = Office 2003, 12.0 = Office 2007, 14.0 = Office 2010
RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Office\14.0\Word\Resiliency\DisabledItems", true);
key.SetValue("63CB962", stream.ToArray(), RegistryValueKind.Binary);
key.Close();

A similar approach can be used to decode the dll path of an existing value like so:

// Let 'bytes' be a byte array containing the binary registry value
BinaryReader binaryReader = new BinaryReader(new MemoryStream(bytes));
binaryReader.ReadInt32(); // Read the first four bytes and ignore
int pathLength = binaryReader.ReadInt32(); // The next four bytes are the length of the path
binaryReader.Close();
if (bytes.Length >= 12 + pathLength)
{
    string path = Encoding.Unicode.GetString(bytes, 12, pathLength - 2);
}
share|improve this answer

Answering my own question.

It's in the registry, under HKCU\Software\Microsoft\Office[version]>\Word\Resiliency\DisabledItems (where [version] is 10.0 for XP, 11.0 for 2003 and 12.0 for 2007).

The keys are Binary keys with names of six (random, as far as I can tell) hex characters.

The value is: 01,00,00,00,x,00,00,00,y,[path],00,00,[name],00,00,00 x is the number of bytes in the path (including the two terminator bytes) and y is the number of bytes in the name (which a "friendly name"). x+y should be the total number of bytes minus ten. x and y are both in hex. I assume that they are actually DWORDs, but I've only ever needed the LSB.

The path is encoded in UCS-2, little-endian, so to give an example, "c:\" is 00,63,00,3a,00,5c

Yes, the binary encoding seems to be the awesomely brilliant encoding of "Take a null terminated ASCII string, translate to Unicode, then take the bytes of that and null-terminate the result"

Note that x and y are counts of bytes, not characters; there are 2 bytes per character in UCS-2.

If you want to block a template (ie a .dot rather than a .dll) then put 00 for y and skip the name element, and the termination (so it ends with three null bytes, not five).

share|improve this answer

According to this MS site, to disable an add-in in word 2007 do the following:

  1. Click the Microsoft Office Button Button image, click Word Options, and then click Add-Ins.
  2. In the Add-ins box, identify the add-in that you want to enable or disable and note the Add-in type located in the Type column.
  3. Select the Add-in type in the Manage box and then click Go.
  4. Select or clear the check box for the Add-in that you want enable or disable and then click OK.
share|improve this answer
    
Yeah, that's one way to do it, but for COM Add-ins, that only works if they are referenced in HKCU; if they're in HKLM, as they usually are, then you have to manually remove the key from HKLM\SOFTWARE\Microsoft\Office\Word\Addins. To disable using that disabled items screen, which will let you disable an HKLM addin on a per-user basis, you need to use the registry hack in my answer. –  Richard Gadsden Aug 3 '09 at 10:16

Note that Eirikur's code works only if the Resiliency\DisabledItems subkey is in place. It looks like Word will add/remove this entire subkey when it disables/enables. So, if you get an exception running the code, you probably need to add the subkey first.

(My post here should probably get moderated, it belongs as a comment but I don't have enough points! Bad start)

share|improve this answer
    
Here, have a +1 which will get you some points. –  Richard Gadsden Oct 16 '10 at 8:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.