Re: Visual Basic Ver 6.0 - Word 2003
From: MikeD (nobody_at_nowhere.edu)
Date: 04/26/04
- Next message: MikeD: "Re: wmi classes and vbscript"
- Previous message: Novice: "Clarify"
- In reply to: Paul: "Visual Basic Ver 6.0 - Word 2003"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 26 Apr 2004 19:09:53 -0400
"Paul" <mmijpv@cox.net> wrote in message
news:A739A8C6-203E-40C6-A563-55BD2476F28E@microsoft.com...
> I have a client that has chhanged from WinNt Server/Win
> 98/Office 2000 to Server 2003/Xp Professional/Office 2003.
> Now he receives the following error when trying to merge
> and print letters using the same VB program:
> error: "Requested object is not available", Run time
> error is 5852
>
> I have the reference of "Microsoft Word 9.0 Object
> LIbrary" in the program.
>
> Can you tell me what the issue is and how to resolve it??
As has been already pointed out, the problem may be the library or possibly
your code which instantiates objects from the library. You should still be
able to reference the 9.0 object library (on your dev PC if it has Word 2000
installed) and your app should work on a target PC even if Office 2003 is
installed on the target PC. However, there are ways to create an instance
of an object from a specific library version. If you did this, it would
*not* work with Office 2003.
For example, this code creates an early-bound instance of a Word.Application
object. However, it is specific to the version 9.0 object library. This
code will ONLY work if Word 2000 is installed. It will not work if any
other version of Word is installed.
Dim oWordApp As Word.Application
Set oWordApp = CreateObject("Word.Application.9")
There would be 2 ways to correct this situation (well, 3, but the 3rd
shouldn't be considered viable because you could have the same problem
again). First would be to drop the ".9" from your Class string:
Set oWordApp = CreateObject("Word.Application")
The second way would be this code:
Set oWordApp = New Word.Application
Oh. The 3rd way, since I mentioned a 3rd, would be this:
Set oWordApp = CreateObject("Word.Application.11")
(But this is not really good since you'd have the exact same problem as you
do now if your app were run on any PC that does not have Word 2003
installed.)
However (now that I think a little more about the error number you're
getting), I'm not sure any of the above information is going to be useful
because I'm not convinced that this is really the problem. If it WERE the
problem, I'd suspect you'd get error number 429 - "ActiveX component can't
create object". Error number 5852 is "Application-defined or object-defined
error". This means that if the problem has anything at all to do with Word,
it's Word that's raising the error back to your VB program and providing an
alternate error description (which VB gladly reports). This implies the
Word object (whatever it may be; I just used Word.Application for example
purposes) is indeed getting instantiated. Do you know the source of the
error? You can get the source via Err.Source.
It's still possible (probable even) it has something to do with the fact
that there's a different version of Word installed than for which the
application was originally written. I'm just not entirely convinced it has
anything to do with the object getting instantiated and/or the library
reference. That means you need to dig deeper into the problem...such as
determining the specific line of code that's causing the error. I'm not
familiar with Word 2003 (I use Word 2000). Perhaps there is an object in
Word 2000 that is no longer available in Word 2003? This *should* break
binary compatibility (meaning you shouldn't be able to instantiate the
object and should therefore get error 429), but with MS.....who knows?
Again, I think you need to pinpoint the line of code causing the error.
Mike
- Next message: MikeD: "Re: wmi classes and vbscript"
- Previous message: Novice: "Clarify"
- In reply to: Paul: "Visual Basic Ver 6.0 - Word 2003"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|