Word Automation: OLE exception error 5981 in Windows 7

Author: Ken Dibble

Posted: 2010-05-27 at 10:29:16

Hi folks,

I have some Word automation code that worked fine in Win 2000 but is not

working in Win 7. Yeah, I'm using Word 97, but I have heard that this

problem can also occur with Word 2003, so let's for the sake of argument

hold off on the jeering and see if there are any solutions, okay? :)

I can get a Word object reference without problems but in the code:

WITH oWord

.documents.add <<< VFP Error 1429, OLE Exception Error 5981 "could

not open macro storage"

Googling this gets a lot of results, which seem to fall into two categories:

Normal.dot is corrupted, or

There's a permissions issue affecting access to Normal.dot

Word had no problem seeing and using Normal.dot in manual operation, but on

the chance that it was subtly corrupted I renamed it as OldNormal.dot and

tried the automation. That should have forced creation of a new

Normal.dot--which it did--but I got the same error.

As for permissions: I'm testing this in Win 7 while running with a Domain

Administrator account. So theoretically I should have permissions to access

everything. However...

I noticed that the default location for Normal.dot in Word 97 is \Program

Files\Microsoft Office\Office". I realize that in Win 7 this is not a

writeable location by default, and I saw that Win 7 had actually put

Normal.dot into the \Virtual Store\ folder in my profile.

So I tried changing the location for Normal.dot to a folder that should be

accessible. I tried both putting it in \Users\Public\Public Documents, and

in my My Documents folder, in each case telling Word to find it there. Word

can see and use the template during manual operation, but during automation

I still get the same error.

After the error--which hangs Word--regardless of whether I forced creation

of a new Normal.dot or let it use the old one--I can see a Word temp file

in the templates location called "~$Normal.dot". The "normal" Normal.dot

file is 27 kb; this temp file is 1 kb, which suggests to me that Word got

as far as creating the temp file but not writing anything to it.

In my Googling I had found a Microsoft KB article (KB 224338) indicating

that one cause of this could be that Win 7 does not actually load the

registry "hive" for the user who installed Word. That doesn't make sense in

this context because I'm running as Domain Administrator, and that's the

account I installed Word in.

But, Word 97 doesn't natively understand NT-style security and to get it to

work on Win 2000 and later you have to explicitly grant restricted user

accounts permissions for various features, and you have to grant them

Modify rights on the \Program Files\Office folder to give them access to

Normal.dot if it's there. Again, that shouldn't be directly relevant to me

because I'm not running as a restricted user--but just in case, I

explicitly granted not just Modify, but Full Control rights to my Domain

User account to everything in the Word tree in the Registry, and to the

\Program Files\Office\ folder tree.

Again, no dice, same error.

So I don't see how this can be either a permissions or corruption problem.

But the MS KB article suggests some things to try. One of them is to start

Word manually before running the automation code. That would not be

desirable because the automation is complex and it would slow it down

considerably. But in any case, that doesn't work--same error. Because of

that I doubt the other suggestions in the article, to somehow load the

appropriate registry hive, or to do a "run as" administrator,

programmatically, would work either. In any case, I don't know how to do

those things.

So... can anyone shed any light on this? Have you had the problem with Word

2003 in Win 7?

Thanks very much in advance.

Ken Dibble

Southern Tier Independence Center, Inc.

www.stic-cil.org

_______________________________________________

Post Messages to: ProFox@leafe.com

Subscription Maintenance: http://leafe.com/mailman/listinfo/profox

OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech

Searchable Archive: http://leafe.com/archives/search/profox

This message: http://leafe.com/archives/byMID/profox/5.2.1.1.1.20100527095230.01c04710@pop3.frontiernet.net

** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.

©2010 Ken Dibble