Strange Automation Issue

  • Thread starter Thread starter Neil Ginsberg
  • Start date Start date
N

Neil Ginsberg

I have a strange situation with my Access 2000 database. I have code in the
database which has worked fine for years, and now all of a sudden doesn't
work fine on one or two of my client's machines. The code opens MS Word
through Automation and then opens a particular Word doc. It's still working
fine on most machines; but on one or two of them, the user is getting an
Automation Error. The code used is as follows:

Dim objWord As Word.Application
Set objWord = New Word.Application
objWord.Documents.Open FileName:=strFilename, _
ConfirmConversions:=False, _
ReadOnly:=False, _
AddToRecentFiles:=False, _
Revert:=False, _
Format:=gcon_wdOpenFormatAuto 'this is global constant with
Word constant value

The Automation Error occurs on the third line, when trying to open the
document (the document does exist, so that's not the problem).

Even stranger than the fact that the problem's only happening on two out of
several dozen machines, is the following. I have a pared-down copy of the
database, that users use to take on the road with them and show to clients.
The pared-down version (call it "App B") was taken from the original (call
it "App A") with some functionality removed. Regarding the above code that's
failing, both App A and App B are identical, and both have the same
references.

Now, here's the really strange part.

On one computer that's having problems, App A fails in the above code. On
the other computer that's having problems, App A works fine in the above
code, but App B fails in that code. So, in the second case, with the same
computer and two identical sets of code, one set fails, the other doesn't.

I've looked at backup copies to see if it was a corruption issue, and
haven't seen any difference. And, as noted, this code has been in place for
years without problems, until just the other day when these problems started
happening.

All of the users have MS Office and the database application installed on
their C drives.

Any assistance would be appreciated.

Thanks!

Neil
 
the user is getting an Automation Error.

Neil

I don't know if this might help pinpoint the problem.

Have you written an error handler to display the
automation error using the vbObjectError constant?

If you need it, the following information relates to the
vbObjectError constant:

1. Subtracting vbObjectError from Err.Number will
indicate the error as defined by the server application.

2. However, if subtracting vbObjectError from Err.Number
results in a number outside the range 0 - 65535, the
error is a VBA error.

Therefore, your error handler might look like:

' Remove the constant added by the server application:
MyError = Err.Number - vbObjectError

' Is the result in the range 0 - 65535?
If MyError > 0 and MyError < 65535 then

Msg = "The object you accessed assigned this number to " & _
"the error: " & MyError & ". The originator of " & _
"the error was: " & Err.Source & ". Press F1 to " & _
"see the originating applications' help topic."

Else ' It's a VBA error:

Msg = "This error " & Err.Number & " is a VBA error. " & _
"Press Help button or F1 for VBA Help topic on " & _
"this error."

End if

Msgbox Msg, , "Object Error", Err.Helpfile, Err.HelpContext


Obviously, this doesn't solve your problem, but it may
help you identify it.

HTH
Geoff
 
I found a couple of posts about this error: both in German! Here's one,
translated by altavista:

"When responding Word from ACCESS (Office 97) out I have the problem that I
get an automation error from ACCESS. The complete error message reads: Run
time error -2147023067 (80070725) Automasierungfehler Incompatible version
of the RPC Stub The common to the fact is that the program on some computers
does not laeueft and on others. On all computers NT 4,0 with service luggage
6a and Office 97 with SP2 runs. I packed some often needed functions into a
class. In this class Word is initalisiert and assigned as object of a
Membervariablen [ set Word=CreateObject"Word.Application")..]. If the Word
object to access, hails it is now tried above error message e.g.
oWord.ChangeFileOpenDirectory sPath. In addition, with each arbitrary other
Word function gives it this message. I have to define tried "oWord" as
Public, but that did not also help me. Does someone have one perhaps taps as
I this error to repair can?"

Ok, that was fun! Now let's try something else.

Are you sure the error occurs on the .Open call? It doesn't occur on the New
Word.Applcation?

Perhaps try:

set objword = createobject ("word.application")

MS says: "When creating an instance of an Microsoft Office application, use
CreateObject instead of New. CreateObject more closely maps to the creation
process used by most Visual C++ clients, and allows for possible changes in
the server's CLSID between versions. CreateObject can be used with both
early-bound and late-bound objects."

HTH,
TC
 
In my case, Err.Number = -2147023067 and vbObjectError = -2147221504.
Subtracting the second from the first I get 198437, which according to your
notes means it's a VBA error. I'm not sure where that gets me, since the VBA
code hasn't changed years and it started being problematic a couple of days
ago. Any ideas?

Thanks,

Neil
 
Are you sure the error occurs on the .Open call? It doesn't occur on the
New
Word.Applcation?

Yes, positive. I thought that was a bit strange myself. It also occurs if I
try to do anything else (i.e., skip the offending line), such as set the
application's Visible property to True, etc. In other Words, it creates the
object fine; but then it won't do anything with it!
Perhaps try:

set objword = createobject ("word.application")

That's the code I'm using. Wait a minute: in my message I posted other code.

OK, I may have stumbled upon something. I just noticed that the original app
I referred to as "App A" uses the code:

Set objWord = New Word.Application

whereas the pared-down app I referred to as "App B" uses:

Set objWord = CreateObject("Word.Application")

On the computer I have access to (via PC Anywhere), App A is working fine,
but App B isn't. So that might be something to try. (Still doesn't explain
why it would all of a sudden start having problems, when my notes show that
I changed the App A code last June -- must have forgotten that I had done
that -- but at least it's a start!)
MS says: "When creating an instance of an Microsoft Office application, use
CreateObject instead of New. CreateObject more closely maps to the creation
process used by most Visual C++ clients, and allows for possible changes in
the server's CLSID between versions. CreateObject can be used with both
early-bound and late-bound objects."

That would actually be the opposite of what I'm finding -- that the one with
New is working, but the one with CreateObject isn't. Oh well, whatever takes
care of the problem. Will try that and see how it goes.
 
Here is a KB article that might be helpful:

INFO: Translating Large Office Automation Error Values
http://support.microsoft.com/default.aspx?scid=kb;en-us;238986&Product=acc2000

It includes a link to this KB article:
INFO: Translating Automation Errors for VB/VBA (Long)
http://support.microsoft.com/default.aspx?kbid=186063


When I ran the MessageText function with the error number you reported, I get the
following result. Note: I had to change the scope of the function from Private to Public.

?MessageText(-2147023067)
Incompatible version of the RPC stub.

Hmmm....what does this helpful message mean? I conducted a search of the Knowledge Base
at:
http://support.microsoft.com/default.aspx?scid=FH;EN-US;KBHOWTO

using the text returned by the MessageText function. I specified "All Microsoft Products"
and "Using: All of the words entered". I found 7 hits, one of which looks particularly
promising:

PRB: Office Automation Fails with an Incompatible RPC Stub Error
http://support.microsoft.com/default.aspx?scid=kb;en-us;320108

I think you may find the answer in the above KB article!

Good Luck, and please report your findings back to the newsgroup.

Tom
___________________________________________


In my case, Err.Number = -2147023067 and vbObjectError = -2147221504.
Subtracting the second from the first I get 198437, which according to your
notes means it's a VBA error. I'm not sure where that gets me, since the VBA
code hasn't changed years and it started being problematic a couple of days
ago. Any ideas?

Thanks,

Neil
 
Neil

Now that this thread has arrived on my machine and
notwithstanding Tom's lead in the other thread (which
perhaps offers more hope).

Word is (I believe) an application that likes to have only
one instance running - although I think I've got multiple
instances running from code before now for reasons
I've never got to the bottom of. Also, I've read some
incomprehensible stuff on memory not being released
when some object variables are set to Nothing after
they've been created using 'New' (even when no other
variables are pointing to the same object).

So, as you're using CreateObject, is there any mileage
in using the GetObject function first (to utilise any
running instance of Word, if Word prefers to be in
memory only once or simply to save system resources).
And, if GetObject produces error 429, then using
CreateObject?

I've seen two coding variations for the above, each of
which uses a boolean variable to leave Word running
if GetObject was successful, but quit Word if
CreateObject was successful. (I can post samples if
you want them.)

No doubt you're destroying object variables when
no longer needed by setting them to Nothing.

Presumably all Office/Windows service packs are
installed on the offending machine.

I realise this doesn't address your specific issue or
the bizarre nature of your code suddenly not
working - but HTH.

Like Tom, I'd be interested in your solution.

Regards
Geoff
 
Thanks for the note. I've had better success with opening new instances in
the past in other situations. Found some bizarre behavior when using
existing instances of Word. Either way, it happens with a clean boot.

Will let you know what happens.

Thanks,

Neil
 
(snip)
Word is (I believe) an application that likes to have only
one instance running

Geoff, that's not really so. There is no problem having multiple instances
of Word running. In some cases, you might *prefer* to have a seperate
instance, to avoid disturbing whatever the user is doing "manually" with an
"existing" copy of Word.

HTH,
TC
 
I guess I could have found the link to the KB article a lot easier, which I gave at the
end of my earlier reply, if I had only known how to search correctly! Go to the Microsoft
KB, and simply enter -2147023067 as the search term. You need to select either
Office 2003 or "All Microsoft Products" in the "Select a Microsoft Product" dropdown.

Note: You won't find anything if you select any of the following products:

Access 2000
Office 2000
Access 2002
Office XP
Access 2003

That's pretty amazing, considering that at the bottom of the article, one finds the
following:
The information in this article applies to:
a.. Microsoft Visual Basic Enterprise Edition for Windows 5.0
b.. Microsoft Visual Basic Enterprise Edition for Windows 6.0
c.. Microsoft Visual C++, 32-bit Professional Edition 5.0
d.. Microsoft Visual C++, 32-bit Professional Edition 6.0
e.. Microsoft Office 2003, All Editions
f.. Microsoft Office XP Developer
and I would have thought that Access 2002 is a part of Office XP, and that Access 2003 is
a part of Office 2003.

_____________________________________________________


Here is a KB article that might be helpful:

INFO: Translating Large Office Automation Error Values
http://support.microsoft.com/default.aspx?scid=kb;en-us;238986&Product=acc2000

It includes a link to this KB article:
INFO: Translating Automation Errors for VB/VBA (Long)
http://support.microsoft.com/default.aspx?kbid=186063


When I ran the MessageText function with the error number you reported, I get the
following result. Note: I had to change the scope of the function from Private to Public.

?MessageText(-2147023067)
Incompatible version of the RPC stub.

Hmmm....what does this helpful message mean? I conducted a search of the Knowledge Base
at:
http://support.microsoft.com/default.aspx?scid=FH;EN-US;KBHOWTO

using the text returned by the MessageText function. I specified "All Microsoft Products"
and "Using: All of the words entered". I found 7 hits, one of which looks particularly
promising:

PRB: Office Automation Fails with an Incompatible RPC Stub Error
http://support.microsoft.com/default.aspx?scid=kb;en-us;320108

I think you may find the answer in the above KB article!

Good Luck, and please report your findings back to the newsgroup.

Tom
___________________________________________


In my case, Err.Number = -2147023067 and vbObjectError = -2147221504.
Subtracting the second from the first I get 198437, which according to your
notes means it's a VBA error. I'm not sure where that gets me, since the VBA
code hasn't changed years and it started being problematic a couple of days
ago. Any ideas?

Thanks,

Neil
 
and I would have thought that Access 2002 is a part of Office XP, and that
Access 2003 is
a part of Office 2003.

Remember: indexers are just poor slobs who have stared at too many
characters over too many cups of coffee for too many hours.

Neil
 
Here's an update on the situation.

You'll recall that there are two machines with problems, and two apps --
"App A" (the original) and "App B" (the pared-down version). One machine had
problems with automation with App A; the other machine worked with App A but
had automation issues with App B. No other machines had problems. At least
part of the puzzle has been resolved.

The user who was having trouble with App A had created a shortcut to Word on
her own, and, it turns out, she found an old copy of Word 97 on the server
and opened that instead of Word 2000. After that, the automation code in
Access didn't work (the reference was to Word 2000) -- though, for some
reason, it was able to open Word and create the reference, but wasn't able
to do anything with it. Once she stopped using that shortcut and began using
Word 2000 again, the problem went away.

So that takes care of that.

Regarding the second issue, as noted in my response to TC, it turns out that
I *did* have different code between App A and App B -- App A had been
changed a few months back, though I forgot about it. App A was using early
binding, and App B was using late binding. And, despite the literature,
early binding was working, but late binding wasn't. So I changed App B to
early binding to match App A, but it's still not working.

And that's where I'm at now.

Neil
All the news that's fit to print.
 
Here's a new twist. I just went into App B with the new early binding code
on the machine that's having problems (no other machine has problems), and
ran the code to open a Word doc. Interesting results. I get a message that
the specific document is locked by another user (the current user of that
machine) and I'm given the option of opening it Read Only, etc. I select
Read Only and the document opens in Word. I then go back to my app, and
there's the same Automation Error as before -- only, instead of it being on
the line that opens the Word doc, it's on the line:

objWord.visible = True

The Word instance was already visible, since I saw the document open. But
that line of code hadn't been executed.

Again, this is the same code that's running fine on other machines.
Interesting.

Neil
 
Keep us posted!

TC


Neil Ginsberg said:
Here's a new twist. I just went into App B with the new early binding code
on the machine that's having problems (no other machine has problems), and
ran the code to open a Word doc. Interesting results. I get a message that
the specific document is locked by another user (the current user of that
machine) and I'm given the option of opening it Read Only, etc. I select
Read Only and the document opens in Word. I then go back to my app, and
there's the same Automation Error as before -- only, instead of it being on
the line that opens the Word doc, it's on the line:

objWord.visible = True

The Word instance was already visible, since I saw the document open. But
that line of code hadn't been executed.

Again, this is the same code that's running fine on other machines.
Interesting.

Neil

Word
 
Thanks for the kick up the proverbial...

You've forced me to re-read about single-use and
multiple-use application classes.

I see that Word's application class is single-use (by
default) or multiple-use. This was the missing piece
of the jigsaw in my understanding of using 'New',
'CreateObject' and 'GetObject'.

This seems amazing now as I've been using these
commands successfully for some time.

Thanks again.
Geoff
 
Again, this is the same code that's running
fine on other machines.

Neil,

Starting from the above premise, if the code runs fine
on other machines, then it seems the problem is not
with the code, but with the user or the machine.

User: Does the user only have read-only rights to
the folder in which the Word document is stored?

(Presumably the file is not read-only if other users
are OK.)

Machine:
* Is the network connection OK?
* Is the software on this machine up-to-date?
* Is the right software being used?

(Don't you just love users who set up shortcuts?
Who'd have thought of that one?)

Waiting with bated breath for your patience to
snap so we get to see the unprintable comments!

Regards
Geoff

PS I don't get the early/late-binding issue if
references were set correctly.
 
I agree that it seems to be the machine. The app appears to have no problems
on any other machine, and, now that the other issue (where the user was
opening an old version of Word) is resolved, I'm chalking this last issue up
to the machine, and stepping away from it for a while. The machine that's
having problems is only used as a dial-up portal for us PCAnywhere users, so
it's not a biggie. So, for now, I'm letting it drop. If I ever get this
resolved, I'll be sure to post it here.

Thanks everyone for your help!

(Sorry about not having any unprintable comments to print! :-) )

Neil
 
Back
Top