I've been having a problem with a third-party add-in to Word that I think is related to ActiveX/automation. Here's what I know:
- When I use the add-in to create multiple new Word files from the vendor's website, when I try to close each document after the first one that was opened, I get the error,
"The file is in use by another application or user. (C:\Users\mooret\AppdData\...\Normal.dotm)"
- I don't know much about ActiveX or automation. I know that the add-in opens Word with the command
wordapp = new ActiveXObject("Word.Application"), which, if I understand things correctly, gets translated to
winword.exe /automation -embedded.
- If Word is already open (by any means), and I open a second instance using the command
winword.exe /automation, then try to close that second instance, I get the error cited above. This tells me the problem is not with the add-in. It's something in my environment.
- I have two machines. As far as I can tell, they're both the same. Same hardware, same Windows 7 build, same properties and add-ins, etc. On one machine I get the error, on the other I do not. I've looked at every setting/reg key/permission I can think of that might be related. I just can't find anything to account for the different behavior.
- On the machine getting the error, when I delete our template and let Word create its own, the error goes away. However, I'm using the same template on both machines. I don't think the problem lies exclusively with the template.
I've read everything Google has to offer on the subject over the last couple weeks and eliminated a lot of possibilities. But I still can't get the error to go away without an AutoClose macro or deleting our custom Normal.dotm. Neither of these are good long-term solutions. And the fact that it works on one machine but not the other tells me that there must be something I'm missing in the environment. Any help would be much appreciated.
After more experimentation, I've learned the following:
- When you open winword.exe using the /automation switch, Word opens as an object instead of an application.
- The errors still only occur when opening Word with the /automation switch.
- Somehow, the problem appears to be related to the styles in the document. I took a clean template that didn't cause the error and started swapping out the XML files within our firm template, and when I swapped out Word's native
styles.xmlfor ours, the error went away.
- Also, when I swap out
styles.xml, Word starts asking if I want to save changes to my document, even when I haven't made any changes. If I'm disconnected from iManage, it also prompts me to connect. UPDATE: 04/11/13 Turns out this was a red herring. Confirmed with our FileSite admin that this just happens because some of our add-ins are calling FileSite. Any variety changes in the environment might cause this behavior.
I'm still digging around in the XML to see what I can learn, but if this prompts any ideas, I'm completely open to suggestions.
After a lot of copying and pasting, trying to figure out exactly what in the
styles.xml was causing the error. Finally, with confidence, I can say this is it:
<w:style w:type="paragraph" w:default="1" w:styleId="Normal"> <w:name w:val="Normal"/> <w:qFormat/> <w:pPr> <w:spacing w:after="0"/> </w:pPr> <w:rPr> <w:rFonts w:ascii="Times New Roman" w:eastAsia="Times New Roman" w:hAnsi="Times New Roman" w:cs="Times New Roman"/> <w:szCs w:val="20"/> <w:lang w:eastAsia="en-US"/> </w:rPr> </w:style>
Breaking it down even further, it comes down to this piece:
w:eastAsia="Times New Roman"
Without that piece, everything goes off without a hitch. Thanks in advance for any help with this.