By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,739 Members | 1,523 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,739 IT Pros & Developers. It's quick & easy.

Problem with Word...

P: n/a
I have a problem with automating MS Word through vb.net

My code is :

Dim objword As new Word.ApplicationClass
Try
objWord.Documents.Open(letterfile)
objWord.Documents.Item(letterfile).Activate()
Catch
MsgBox("Error - Word Not running properly - letterfile=" & letterfile &
vbCrLf & " Error = " & Err.Description)
openletter = True
Exit Function
End Try

This works fine on my development machine with Word XP installed. However,
when installed on another PC (with Word 2000 installed) it fails with an
error "Object reference not set to an instance of an object". I can tell
from the task manager that Word has started up and is running but beyond
that I can't work out what the problem is. I have distributed the
application simply by using the Windows installer project which seems to
distribute an interop.word library.

I don't know what else to try.... I'm presuming that as I have Word XP on
my development machine that any word code should be backwardly compatible.

Any thoughts?

Regards
Simon
Nov 20 '05 #1
Share this Question
Share on Google+
16 Replies


P: n/a
First question is if all the versions of office are the same ?. if not it
may be that the class hierarchy has changed between the two.
Regards - OHM
Simon Verona wrote:
I have a problem with automating MS Word through vb.net

My code is :

Dim objword As new Word.ApplicationClass
Try
objWord.Documents.Open(letterfile)
objWord.Documents.Item(letterfile).Activate()
Catch
MsgBox("Error - Word Not running properly - letterfile=" & letterfile
& vbCrLf & " Error = " & Err.Description)
openletter = True
Exit Function
End Try

This works fine on my development machine with Word XP installed.
However, when installed on another PC (with Word 2000 installed) it
fails with an error "Object reference not set to an instance of an
object". I can tell from the task manager that Word has started up
and is running but beyond that I can't work out what the problem is.
I have distributed the application simply by using the Windows
installer project which seems to distribute an interop.word library.

I don't know what else to try.... I'm presuming that as I have Word
XP on my development machine that any word code should be backwardly
compatible.

Any thoughts?

Regards
Simon


--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com
Nov 20 '05 #2

P: n/a
No, the versions of office are different...

However, this is a port of code that worked fine on vb6! I suspect
therefore that the office stuff should work the same...

Regards
Simon
"One Handed Man [ OHM# ]" <O_H_M{at}BTInternet{dot}com> wrote in message
news:uk****************@tk2msftngp13.phx.gbl...
First question is if all the versions of office are the same ?. if not it
may be that the class hierarchy has changed between the two.
Regards - OHM
Simon Verona wrote:
I have a problem with automating MS Word through vb.net

My code is :

Dim objword As new Word.ApplicationClass
Try
objWord.Documents.Open(letterfile)
objWord.Documents.Item(letterfile).Activate()
Catch
MsgBox("Error - Word Not running properly - letterfile=" & letterfile
& vbCrLf & " Error = " & Err.Description)
openletter = True
Exit Function
End Try

This works fine on my development machine with Word XP installed.
However, when installed on another PC (with Word 2000 installed) it
fails with an error "Object reference not set to an instance of an
object". I can tell from the task manager that Word has started up
and is running but beyond that I can't work out what the problem is.
I have distributed the application simply by using the Windows
installer project which seems to distribute an interop.word library.

I don't know what else to try.... I'm presuming that as I have Word
XP on my development machine that any word code should be backwardly
compatible.

Any thoughts?

Regards
Simon


--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com

Nov 20 '05 #3

P: n/a
Hi Simon,

This may seem like a really "Dumb" question, so if it is please forgive me,
but does letterfile actually exists in the path you are looking for it in
the system which does not work ?, I presume it fails in the Try section
because the objWord . . .Activate?

Regards - OHM
Simon Verona wrote:
No, the versions of office are different...

However, this is a port of code that worked fine on vb6! I suspect
therefore that the office stuff should work the same...

Regards
Simon
"One Handed Man [ OHM# ]" <O_H_M{at}BTInternet{dot}com> wrote in
message news:uk****************@tk2msftngp13.phx.gbl...
First question is if all the versions of office are the same ?. if
not it may be that the class hierarchy has changed between the two.
Regards - OHM
Simon Verona wrote:
I have a problem with automating MS Word through vb.net

My code is :

Dim objword As new Word.ApplicationClass
Try
objWord.Documents.Open(letterfile)
objWord.Documents.Item(letterfile).Activate()
Catch
MsgBox("Error - Word Not running properly - letterfile=" &
letterfile & vbCrLf & " Error = " & Err.Description)
openletter = True
Exit Function
End Try

This works fine on my development machine with Word XP installed.
However, when installed on another PC (with Word 2000 installed) it
fails with an error "Object reference not set to an instance of an
object". I can tell from the task manager that Word has started up
and is running but beyond that I can't work out what the problem is.
I have distributed the application simply by using the Windows
installer project which seems to distribute an interop.word library.

I don't know what else to try.... I'm presuming that as I have Word
XP on my development machine that any word code should be backwardly
compatible.

Any thoughts?

Regards
Simon


--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com


--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com
Nov 20 '05 #4

P: n/a
yes, the letterfile does actually exist (I thought that this was the problem
myself)... It's the same letterfile on both my development machine (on which
it works) and the other PC (which it doesn't) ... The document in question
is on a networked drive so it is *exactly* the same document.

You can open the document manually from either machine...

Regards
Simon

"One Handed Man [ OHM# ]" <O_H_M{at}BTInternet{dot}com> wrote in message
news:et*************@TK2MSFTNGP11.phx.gbl...
Hi Simon,

This may seem like a really "Dumb" question, so if it is please forgive me, but does letterfile actually exists in the path you are looking for it in
the system which does not work ?, I presume it fails in the Try section
because the objWord . . .Activate?

Regards - OHM
Simon Verona wrote:
No, the versions of office are different...

However, this is a port of code that worked fine on vb6! I suspect
therefore that the office stuff should work the same...

Regards
Simon
"One Handed Man [ OHM# ]" <O_H_M{at}BTInternet{dot}com> wrote in
message news:uk****************@tk2msftngp13.phx.gbl...
First question is if all the versions of office are the same ?. if
not it may be that the class hierarchy has changed between the two.
Regards - OHM
Simon Verona wrote:
I have a problem with automating MS Word through vb.net

My code is :

Dim objword As new Word.ApplicationClass
Try
objWord.Documents.Open(letterfile)
objWord.Documents.Item(letterfile).Activate()
Catch
MsgBox("Error - Word Not running properly - letterfile=" &
letterfile & vbCrLf & " Error = " & Err.Description)
openletter = True
Exit Function
End Try

This works fine on my development machine with Word XP installed.
However, when installed on another PC (with Word 2000 installed) it
fails with an error "Object reference not set to an instance of an
object". I can tell from the task manager that Word has started up
and is running but beyond that I can't work out what the problem is.
I have distributed the application simply by using the Windows
installer project which seems to distribute an interop.word library.

I don't know what else to try.... I'm presuming that as I have Word
XP on my development machine that any word code should be backwardly
compatible.

Any thoughts?

Regards
Simon

--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com


--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com

Nov 20 '05 #5

P: n/a
One last thought !

Does your document reference use UNC pathnames IE (
\\SERVER\RESOURCE\DOCUMENTNAME ). If this is the case then maybe your
version of word running on Win2K does not support this from a code point of
view ( although I doubt it ).

One alternative may be to put the letterfile on the users hard disk and
change the path to a local direcectory\filename. At least this would rule
this out.

Regards - OHM
Simon Verona wrote:
yes, the letterfile does actually exist (I thought that this was the
problem myself)... It's the same letterfile on both my development
machine (on which it works) and the other PC (which it doesn't) ...
The document in question is on a networked drive so it is *exactly*
the same document.

You can open the document manually from either machine...

Regards
Simon

"One Handed Man [ OHM# ]" <O_H_M{at}BTInternet{dot}com> wrote in
message news:et*************@TK2MSFTNGP11.phx.gbl...
Hi Simon,

This may seem like a really "Dumb" question, so if it is please
forgive me, but does letterfile actually exists in the path you are
looking for it in the system which does not work ?, I presume it
fails in the Try section because the objWord . . .Activate?

Regards - OHM
Simon Verona wrote:
No, the versions of office are different...

However, this is a port of code that worked fine on vb6! I suspect
therefore that the office stuff should work the same...

Regards
Simon
"One Handed Man [ OHM# ]" <O_H_M{at}BTInternet{dot}com> wrote in
message news:uk****************@tk2msftngp13.phx.gbl...
First question is if all the versions of office are the same ?. if
not it may be that the class hierarchy has changed between the two.
Regards - OHM
Simon Verona wrote:
> I have a problem with automating MS Word through vb.net
>
> My code is :
>
> Dim objword As new Word.ApplicationClass
> Try
> objWord.Documents.Open(letterfile)
> objWord.Documents.Item(letterfile).Activate()
> Catch
> MsgBox("Error - Word Not running properly - letterfile=" &
> letterfile & vbCrLf & " Error = " & Err.Description)
> openletter = True
> Exit Function
> End Try
>
> This works fine on my development machine with Word XP installed.
> However, when installed on another PC (with Word 2000 installed)
> it fails with an error "Object reference not set to an instance
> of an object". I can tell from the task manager that Word has
> started up and is running but beyond that I can't work out what
> the problem is. I have distributed the application simply by
> using the Windows installer project which seems to distribute an
> interop.word library.
>
> I don't know what else to try.... I'm presuming that as I have
> Word XP on my development machine that any word code should be
> backwardly compatible.
>
> Any thoughts?
>
> Regards
> Simon

--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com


--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com


--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com
Nov 20 '05 #6

P: n/a
Tried that.. the document was originally on a mapped network drive, but I
copied it local.

I'm running out of options now!!

I'm just hoping that somebody has some inspiration for me!!!

I'm presuming that I don't have to do something special with the install
scripts to distribute/use the correct version of the Word Objects??

Regards
Simon
"One Handed Man [ OHM# ]" <O_H_M{at}BTInternet{dot}com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
One last thought !

Does your document reference use UNC pathnames IE (
\\SERVER\RESOURCE\DOCUMENTNAME ). If this is the case then maybe your
version of word running on Win2K does not support this from a code point of view ( although I doubt it ).

One alternative may be to put the letterfile on the users hard disk and
change the path to a local direcectory\filename. At least this would rule
this out.

Regards - OHM
Simon Verona wrote:
yes, the letterfile does actually exist (I thought that this was the
problem myself)... It's the same letterfile on both my development
machine (on which it works) and the other PC (which it doesn't) ...
The document in question is on a networked drive so it is *exactly*
the same document.

You can open the document manually from either machine...

Regards
Simon

"One Handed Man [ OHM# ]" <O_H_M{at}BTInternet{dot}com> wrote in
message news:et*************@TK2MSFTNGP11.phx.gbl...
Hi Simon,

This may seem like a really "Dumb" question, so if it is please
forgive me, but does letterfile actually exists in the path you are
looking for it in the system which does not work ?, I presume it
fails in the Try section because the objWord . . .Activate?

Regards - OHM
Simon Verona wrote:
No, the versions of office are different...

However, this is a port of code that worked fine on vb6! I suspect
therefore that the office stuff should work the same...

Regards
Simon
"One Handed Man [ OHM# ]" <O_H_M{at}BTInternet{dot}com> wrote in
message news:uk****************@tk2msftngp13.phx.gbl...
> First question is if all the versions of office are the same ?. if
> not it may be that the class hierarchy has changed between the two.
>
>
> Regards - OHM
>
>
> Simon Verona wrote:
>> I have a problem with automating MS Word through vb.net
>>
>> My code is :
>>
>> Dim objword As new Word.ApplicationClass
>> Try
>> objWord.Documents.Open(letterfile)
>> objWord.Documents.Item(letterfile).Activate()
>> Catch
>> MsgBox("Error - Word Not running properly - letterfile=" &
>> letterfile & vbCrLf & " Error = " & Err.Description)
>> openletter = True
>> Exit Function
>> End Try
>>
>> This works fine on my development machine with Word XP installed.
>> However, when installed on another PC (with Word 2000 installed)
>> it fails with an error "Object reference not set to an instance
>> of an object". I can tell from the task manager that Word has
>> started up and is running but beyond that I can't work out what
>> the problem is. I have distributed the application simply by
>> using the Windows installer project which seems to distribute an
>> interop.word library.
>>
>> I don't know what else to try.... I'm presuming that as I have
>> Word XP on my development machine that any word code should be
>> backwardly compatible.
>>
>> Any thoughts?
>>
>> Regards
>> Simon
>
> --
> Best Regards - OHM
>
> O_H_M{at}BTInternet{dot}com

--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com


--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com

Nov 20 '05 #7

P: n/a
Simon,

Good point, can you establish if the Msoffice DLL you need is on the target
? I'm sorry but I have to leave now, let me know how you get on.

Regards - OHM


Simon Verona wrote:
Tried that.. the document was originally on a mapped network drive,
but I copied it local.

I'm running out of options now!!

I'm just hoping that somebody has some inspiration for me!!!

I'm presuming that I don't have to do something special with the
install scripts to distribute/use the correct version of the Word
Objects??

Regards
Simon
"One Handed Man [ OHM# ]" <O_H_M{at}BTInternet{dot}com> wrote in
message news:%2****************@TK2MSFTNGP09.phx.gbl...
One last thought !

Does your document reference use UNC pathnames IE (
\\SERVER\RESOURCE\DOCUMENTNAME ). If this is the case then maybe
your version of word running on Win2K does not support this from a
code point of view ( although I doubt it ).

One alternative may be to put the letterfile on the users hard disk
and change the path to a local direcectory\filename. At least this
would rule this out.

Regards - OHM
Simon Verona wrote:
yes, the letterfile does actually exist (I thought that this was the
problem myself)... It's the same letterfile on both my development
machine (on which it works) and the other PC (which it doesn't) ...
The document in question is on a networked drive so it is *exactly*
the same document.

You can open the document manually from either machine...

Regards
Simon

"One Handed Man [ OHM# ]" <O_H_M{at}BTInternet{dot}com> wrote in
message news:et*************@TK2MSFTNGP11.phx.gbl...
Hi Simon,

This may seem like a really "Dumb" question, so if it is please
forgive me, but does letterfile actually exists in the path you are
looking for it in the system which does not work ?, I presume it
fails in the Try section because the objWord . . .Activate?

Regards - OHM
Simon Verona wrote:
> No, the versions of office are different...
>
> However, this is a port of code that worked fine on vb6! I
> suspect therefore that the office stuff should work the same...
>
> Regards
> Simon
> "One Handed Man [ OHM# ]" <O_H_M{at}BTInternet{dot}com> wrote in
> message news:uk****************@tk2msftngp13.phx.gbl...
>> First question is if all the versions of office are the same ?.
>> if not it may be that the class hierarchy has changed between
>> the two.
>>
>>
>> Regards - OHM
>>
>>
>> Simon Verona wrote:
>>> I have a problem with automating MS Word through vb.net
>>>
>>> My code is :
>>>
>>> Dim objword As new Word.ApplicationClass
>>> Try
>>> objWord.Documents.Open(letterfile)
>>> objWord.Documents.Item(letterfile).Activate()
>>> Catch
>>> MsgBox("Error - Word Not running properly - letterfile=" &
>>> letterfile & vbCrLf & " Error = " & Err.Description)
>>> openletter = True
>>> Exit Function
>>> End Try
>>>
>>> This works fine on my development machine with Word XP
>>> installed. However, when installed on another PC (with Word
>>> 2000 installed) it fails with an error "Object reference not
>>> set to an instance of an object". I can tell from the task
>>> manager that Word has started up and is running but beyond that
>>> I can't work out what the problem is. I have distributed the
>>> application simply by using the Windows installer project which
>>> seems to distribute an interop.word library.
>>>
>>> I don't know what else to try.... I'm presuming that as I have
>>> Word XP on my development machine that any word code should be
>>> backwardly compatible.
>>>
>>> Any thoughts?
>>>
>>> Regards
>>> Simon
>>
>> --
>> Best Regards - OHM
>>
>> O_H_M{at}BTInternet{dot}com

--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com


--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com


--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com
Nov 20 '05 #8

P: n/a
It certainly *appears* to be...

If I add the line objword.visible=true after the dim objword.. line then
I see Word appear on screen... This *suggests* that I have some sort of link
to the correct dll's!!! It just seems to refuse to open a document!!

I can even do things like msgbox(objword.version) which shows the correct
version of word on each of the PC's (v10.0 on the development machine, v9.0
on the client).

Regards
Simon
"One Handed Man [ OHM# ]" <O_H_M{at}BTInternet{dot}com> wrote in message
news:OA**************@TK2MSFTNGP10.phx.gbl...
Simon,

Good point, can you establish if the Msoffice DLL you need is on the target ? I'm sorry but I have to leave now, let me know how you get on.

Regards - OHM


Simon Verona wrote:
Tried that.. the document was originally on a mapped network drive,
but I copied it local.

I'm running out of options now!!

I'm just hoping that somebody has some inspiration for me!!!

I'm presuming that I don't have to do something special with the
install scripts to distribute/use the correct version of the Word
Objects??

Regards
Simon
"One Handed Man [ OHM# ]" <O_H_M{at}BTInternet{dot}com> wrote in
message news:%2****************@TK2MSFTNGP09.phx.gbl...
One last thought !

Does your document reference use UNC pathnames IE (
\\SERVER\RESOURCE\DOCUMENTNAME ). If this is the case then maybe
your version of word running on Win2K does not support this from a
code point of view ( although I doubt it ).

One alternative may be to put the letterfile on the users hard disk
and change the path to a local direcectory\filename. At least this
would rule this out.

Regards - OHM
Simon Verona wrote:
yes, the letterfile does actually exist (I thought that this was the
problem myself)... It's the same letterfile on both my development
machine (on which it works) and the other PC (which it doesn't) ...
The document in question is on a networked drive so it is *exactly*
the same document.

You can open the document manually from either machine...

Regards
Simon

"One Handed Man [ OHM# ]" <O_H_M{at}BTInternet{dot}com> wrote in
message news:et*************@TK2MSFTNGP11.phx.gbl...
> Hi Simon,
>
> This may seem like a really "Dumb" question, so if it is please
> forgive me, but does letterfile actually exists in the path you are
> looking for it in the system which does not work ?, I presume it
> fails in the Try section because the objWord . . .Activate?
>
> Regards - OHM
>
>
> Simon Verona wrote:
>> No, the versions of office are different...
>>
>> However, this is a port of code that worked fine on vb6! I
>> suspect therefore that the office stuff should work the same...
>>
>> Regards
>> Simon
>> "One Handed Man [ OHM# ]" <O_H_M{at}BTInternet{dot}com> wrote in
>> message news:uk****************@tk2msftngp13.phx.gbl...
>>> First question is if all the versions of office are the same ?.
>>> if not it may be that the class hierarchy has changed between
>>> the two.
>>>
>>>
>>> Regards - OHM
>>>
>>>
>>> Simon Verona wrote:
>>>> I have a problem with automating MS Word through vb.net
>>>>
>>>> My code is :
>>>>
>>>> Dim objword As new Word.ApplicationClass
>>>> Try
>>>> objWord.Documents.Open(letterfile)
>>>> objWord.Documents.Item(letterfile).Activate()
>>>> Catch
>>>> MsgBox("Error - Word Not running properly - letterfile=" &
>>>> letterfile & vbCrLf & " Error = " & Err.Description)
>>>> openletter = True
>>>> Exit Function
>>>> End Try
>>>>
>>>> This works fine on my development machine with Word XP
>>>> installed. However, when installed on another PC (with Word
>>>> 2000 installed) it fails with an error "Object reference not
>>>> set to an instance of an object". I can tell from the task
>>>> manager that Word has started up and is running but beyond that
>>>> I can't work out what the problem is. I have distributed the
>>>> application simply by using the Windows installer project which
>>>> seems to distribute an interop.word library.
>>>>
>>>> I don't know what else to try.... I'm presuming that as I have
>>>> Word XP on my development machine that any word code should be
>>>> backwardly compatible.
>>>>
>>>> Any thoughts?
>>>>
>>>> Regards
>>>> Simon
>>>
>>> --
>>> Best Regards - OHM
>>>
>>> O_H_M{at}BTInternet{dot}com
>
> --
> Best Regards - OHM
>
> O_H_M{at}BTInternet{dot}com

--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com


--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com

Nov 20 '05 #9

P: n/a
Then is it the document itself which is trying to access a resource which
does not exist onthe target ?

OHM

Simon Verona wrote:
It certainly *appears* to be...

If I add the line objword.visible=true after the dim objword..
line then I see Word appear on screen... This *suggests* that I have
some sort of link to the correct dll's!!! It just seems to refuse to
open a document!!

I can even do things like msgbox(objword.version) which shows the
correct version of word on each of the PC's (v10.0 on the development
machine, v9.0 on the client).

Regards
Simon
"One Handed Man [ OHM# ]" <O_H_M{at}BTInternet{dot}com> wrote in
message news:OA**************@TK2MSFTNGP10.phx.gbl...
Simon,

Good point, can you establish if the Msoffice DLL you need is on the
target ? I'm sorry but I have to leave now, let me know how you get
on.

Regards - OHM


Simon Verona wrote:
Tried that.. the document was originally on a mapped network drive,
but I copied it local.

I'm running out of options now!!

I'm just hoping that somebody has some inspiration for me!!!

I'm presuming that I don't have to do something special with the
install scripts to distribute/use the correct version of the Word
Objects??

Regards
Simon
"One Handed Man [ OHM# ]" <O_H_M{at}BTInternet{dot}com> wrote in
message news:%2****************@TK2MSFTNGP09.phx.gbl...
One last thought !

Does your document reference use UNC pathnames IE (
\\SERVER\RESOURCE\DOCUMENTNAME ). If this is the case then maybe
your version of word running on Win2K does not support this from a
code point of view ( although I doubt it ).

One alternative may be to put the letterfile on the users hard disk
and change the path to a local direcectory\filename. At least this
would rule this out.

Regards - OHM
Simon Verona wrote:
> yes, the letterfile does actually exist (I thought that this was
> the problem myself)... It's the same letterfile on both my
> development machine (on which it works) and the other PC (which
> it doesn't) ... The document in question is on a networked drive
> so it is *exactly* the same document.
>
> You can open the document manually from either machine...
>
> Regards
> Simon
>
> "One Handed Man [ OHM# ]" <O_H_M{at}BTInternet{dot}com> wrote in
> message news:et*************@TK2MSFTNGP11.phx.gbl...
>> Hi Simon,
>>
>> This may seem like a really "Dumb" question, so if it is please
>> forgive me, but does letterfile actually exists in the path you
>> are looking for it in the system which does not work ?, I
>> presume it fails in the Try section because the objWord . .
>> .Activate?
>>
>> Regards - OHM
>>
>>
>> Simon Verona wrote:
>>> No, the versions of office are different...
>>>
>>> However, this is a port of code that worked fine on vb6! I
>>> suspect therefore that the office stuff should work the same...
>>>
>>> Regards
>>> Simon
>>> "One Handed Man [ OHM# ]" <O_H_M{at}BTInternet{dot}com> wrote in
>>> message news:uk****************@tk2msftngp13.phx.gbl...
>>>> First question is if all the versions of office are the same ?.
>>>> if not it may be that the class hierarchy has changed between
>>>> the two.
>>>>
>>>>
>>>> Regards - OHM
>>>>
>>>>
>>>> Simon Verona wrote:
>>>>> I have a problem with automating MS Word through vb.net
>>>>>
>>>>> My code is :
>>>>>
>>>>> Dim objword As new Word.ApplicationClass
>>>>> Try
>>>>> objWord.Documents.Open(letterfile)
>>>>> objWord.Documents.Item(letterfile).Activate()
>>>>> Catch
>>>>> MsgBox("Error - Word Not running properly - letterfile=" &
>>>>> letterfile & vbCrLf & " Error = " & Err.Description)
>>>>> openletter = True
>>>>> Exit Function
>>>>> End Try
>>>>>
>>>>> This works fine on my development machine with Word XP
>>>>> installed. However, when installed on another PC (with Word
>>>>> 2000 installed) it fails with an error "Object reference not
>>>>> set to an instance of an object". I can tell from the task
>>>>> manager that Word has started up and is running but beyond
>>>>> that I can't work out what the problem is. I have distributed
>>>>> the application simply by using the Windows installer project
>>>>> which seems to distribute an interop.word library.
>>>>>
>>>>> I don't know what else to try.... I'm presuming that as I
>>>>> have Word XP on my development machine that any word code
>>>>> should be backwardly compatible.
>>>>>
>>>>> Any thoughts?
>>>>>
>>>>> Regards
>>>>> Simon
>>>>
>>>> --
>>>> Best Regards - OHM
>>>>
>>>> O_H_M{at}BTInternet{dot}com
>>
>> --
>> Best Regards - OHM
>>
>> O_H_M{at}BTInternet{dot}com

--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com


--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com


--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com
Nov 20 '05 #10

P: n/a
I'll try other documents.... the document is pretty much self contained,
and opens in Word on it's own...

It's mystifying me !!!

Regards
Simon
"One Handed Man [ OHM# ]" <O_H_M{at}BTInternet{dot}com> wrote in message
news:uW**************@TK2MSFTNGP11.phx.gbl...
Then is it the document itself which is trying to access a resource which
does not exist onthe target ?

OHM

Simon Verona wrote:
It certainly *appears* to be...

If I add the line objword.visible=true after the dim objword..
line then I see Word appear on screen... This *suggests* that I have
some sort of link to the correct dll's!!! It just seems to refuse to
open a document!!

I can even do things like msgbox(objword.version) which shows the
correct version of word on each of the PC's (v10.0 on the development
machine, v9.0 on the client).

Regards
Simon
"One Handed Man [ OHM# ]" <O_H_M{at}BTInternet{dot}com> wrote in
message news:OA**************@TK2MSFTNGP10.phx.gbl...
Simon,

Good point, can you establish if the Msoffice DLL you need is on the
target ? I'm sorry but I have to leave now, let me know how you get
on.

Regards - OHM


Simon Verona wrote:
Tried that.. the document was originally on a mapped network drive,
but I copied it local.

I'm running out of options now!!

I'm just hoping that somebody has some inspiration for me!!!

I'm presuming that I don't have to do something special with the
install scripts to distribute/use the correct version of the Word
Objects??

Regards
Simon
"One Handed Man [ OHM# ]" <O_H_M{at}BTInternet{dot}com> wrote in
message news:%2****************@TK2MSFTNGP09.phx.gbl...
> One last thought !
>
> Does your document reference use UNC pathnames IE (
> \\SERVER\RESOURCE\DOCUMENTNAME ). If this is the case then maybe
> your version of word running on Win2K does not support this from a
> code point of view ( although I doubt it ).
>
> One alternative may be to put the letterfile on the users hard disk
> and change the path to a local direcectory\filename. At least this
> would rule this out.
>
> Regards - OHM
>
>
> Simon Verona wrote:
>> yes, the letterfile does actually exist (I thought that this was
>> the problem myself)... It's the same letterfile on both my
>> development machine (on which it works) and the other PC (which
>> it doesn't) ... The document in question is on a networked drive
>> so it is *exactly* the same document.
>>
>> You can open the document manually from either machine...
>>
>> Regards
>> Simon
>>
>> "One Handed Man [ OHM# ]" <O_H_M{at}BTInternet{dot}com> wrote in
>> message news:et*************@TK2MSFTNGP11.phx.gbl...
>>> Hi Simon,
>>>
>>> This may seem like a really "Dumb" question, so if it is please
>>> forgive me, but does letterfile actually exists in the path you
>>> are looking for it in the system which does not work ?, I
>>> presume it fails in the Try section because the objWord . .
>>> .Activate?
>>>
>>> Regards - OHM
>>>
>>>
>>> Simon Verona wrote:
>>>> No, the versions of office are different...
>>>>
>>>> However, this is a port of code that worked fine on vb6! I
>>>> suspect therefore that the office stuff should work the same...
>>>>
>>>> Regards
>>>> Simon
>>>> "One Handed Man [ OHM# ]" <O_H_M{at}BTInternet{dot}com> wrote in
>>>> message news:uk****************@tk2msftngp13.phx.gbl...
>>>>> First question is if all the versions of office are the same ?.
>>>>> if not it may be that the class hierarchy has changed between
>>>>> the two.
>>>>>
>>>>>
>>>>> Regards - OHM
>>>>>
>>>>>
>>>>> Simon Verona wrote:
>>>>>> I have a problem with automating MS Word through vb.net
>>>>>>
>>>>>> My code is :
>>>>>>
>>>>>> Dim objword As new Word.ApplicationClass
>>>>>> Try
>>>>>> objWord.Documents.Open(letterfile)
>>>>>> objWord.Documents.Item(letterfile).Activate()
>>>>>> Catch
>>>>>> MsgBox("Error - Word Not running properly - letterfile=" &
>>>>>> letterfile & vbCrLf & " Error = " & Err.Description)
>>>>>> openletter = True
>>>>>> Exit Function
>>>>>> End Try
>>>>>>
>>>>>> This works fine on my development machine with Word XP
>>>>>> installed. However, when installed on another PC (with Word
>>>>>> 2000 installed) it fails with an error "Object reference not
>>>>>> set to an instance of an object". I can tell from the task
>>>>>> manager that Word has started up and is running but beyond
>>>>>> that I can't work out what the problem is. I have distributed
>>>>>> the application simply by using the Windows installer project
>>>>>> which seems to distribute an interop.word library.
>>>>>>
>>>>>> I don't know what else to try.... I'm presuming that as I
>>>>>> have Word XP on my development machine that any word code
>>>>>> should be backwardly compatible.
>>>>>>
>>>>>> Any thoughts?
>>>>>>
>>>>>> Regards
>>>>>> Simon
>>>>>
>>>>> --
>>>>> Best Regards - OHM
>>>>>
>>>>> O_H_M{at}BTInternet{dot}com
>>>
>>> --
>>> Best Regards - OHM
>>>
>>> O_H_M{at}BTInternet{dot}com
>
> --
> Best Regards - OHM
>
> O_H_M{at}BTInternet{dot}com

--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com


--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com

Nov 20 '05 #11

P: n/a
I suspect the problem is with the DLL. An application that is developed
with an older version of Word is forward compatible to newer versions of
Word. For exmaple, an application developed for Word 2000 will (usually)
work fine with Word XP or Word 2003. The reverse isn't true -- the Word
DLLs aren't backwards compatible.

You should have Word 2000 installed on your development machine, and your
project should refernce the Word/Office 9.0 type libraries (for Office 2000)
instead of the Office XP PIAs or the 10.0 type libraries. That will
probably solve your problem, or at least make it easier to debug.

Hope this helps,
Robert Jacobson

"Simon Verona" <ne**@aphroditeuk.com> wrote in message
news:e6**************@TK2MSFTNGP11.phx.gbl...
I have a problem with automating MS Word through vb.net

My code is :

Dim objword As new Word.ApplicationClass
Try
objWord.Documents.Open(letterfile)
objWord.Documents.Item(letterfile).Activate()
Catch
MsgBox("Error - Word Not running properly - letterfile=" & letterfile &
vbCrLf & " Error = " & Err.Description)
openletter = True
Exit Function
End Try

This works fine on my development machine with Word XP installed. However, when installed on another PC (with Word 2000 installed) it fails with an
error "Object reference not set to an instance of an object". I can tell
from the task manager that Word has started up and is running but beyond
that I can't work out what the problem is. I have distributed the
application simply by using the Windows installer project which seems to
distribute an interop.word library.

I don't know what else to try.... I'm presuming that as I have Word XP on
my development machine that any word code should be backwardly compatible.

Any thoughts?

Regards
Simon

Nov 20 '05 #12

P: n/a
aha.... I run Office XP on my development machine...

Is there anyway of just installing the office 200 dll's on my machine (I
don't particularly want to downgrade)??

Regards
Simon
"Robert Jacobson" <rj**********************@nospam.com> wrote in message
news:u0**************@TK2MSFTNGP09.phx.gbl...
I suspect the problem is with the DLL. An application that is developed
with an older version of Word is forward compatible to newer versions of
Word. For exmaple, an application developed for Word 2000 will (usually)
work fine with Word XP or Word 2003. The reverse isn't true -- the Word
DLLs aren't backwards compatible.

You should have Word 2000 installed on your development machine, and your
project should refernce the Word/Office 9.0 type libraries (for Office 2000) instead of the Office XP PIAs or the 10.0 type libraries. That will
probably solve your problem, or at least make it easier to debug.

Hope this helps,
Robert Jacobson

"Simon Verona" <ne**@aphroditeuk.com> wrote in message
news:e6**************@TK2MSFTNGP11.phx.gbl...
I have a problem with automating MS Word through vb.net

My code is :

Dim objword As new Word.ApplicationClass
Try
objWord.Documents.Open(letterfile)
objWord.Documents.Item(letterfile).Activate()
Catch
MsgBox("Error - Word Not running properly - letterfile=" & letterfile &
vbCrLf & " Error = " & Err.Description)
openletter = True
Exit Function
End Try

This works fine on my development machine with Word XP installed.

However,
when installed on another PC (with Word 2000 installed) it fails with an
error "Object reference not set to an instance of an object". I can tell from the task manager that Word has started up and is running but beyond
that I can't work out what the problem is. I have distributed the
application simply by using the Windows installer project which seems to
distribute an interop.word library.

I don't know what else to try.... I'm presuming that as I have Word XP on my development machine that any word code should be backwardly compatible.
Any thoughts?

Regards
Simon


Nov 20 '05 #13

P: n/a
> Word. For exmaple, an application developed for Word 2000 will (usually)
work fine with Word XP or Word 2003. The reverse isn't true -- the Word
DLLs aren't backwards compatible.


That's not true I'm afraid. Microsoft broke binary compatability between
Office 2000 and XP. Most of the functions are still there but you must not
use early binding - late binding must be used.

Rob.
Nov 20 '05 #14

P: n/a
So do I use the object libraries from XP or 2000 to get the job done? I
can probably change the code to late-binding using a OBJECT variable and a
createobject statement etc...

Regards
Simon
"Rob Nicholson" <rob.nicholson@nospam_unforgettable.com> wrote in message
news:99******************@newsfep4-glfd.server.ntli.net...
Word. For exmaple, an application developed for Word 2000 will (usually) work fine with Word XP or Word 2003. The reverse isn't true -- the Word
DLLs aren't backwards compatible.


That's not true I'm afraid. Microsoft broke binary compatability between
Office 2000 and XP. Most of the functions are still there but you must not
use early binding - late binding must be used.

Rob.

Nov 20 '05 #15

P: n/a
Use the Word 2000 object libraries. (Ideally, you should have Word 2000
installed on your test machine.) It should then work fine with later
versions of Word -- but test to make sure.
"Simon Verona" <ne**@aphroditeuk.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
So do I use the object libraries from XP or 2000 to get the job done? I
can probably change the code to late-binding using a OBJECT variable and a
createobject statement etc...

Regards
Simon
"Rob Nicholson" <rob.nicholson@nospam_unforgettable.com> wrote in message
news:99******************@newsfep4-glfd.server.ntli.net...
Word. For exmaple, an application developed for Word 2000 will (usually) work fine with Word XP or Word 2003. The reverse isn't true -- the Word DLLs aren't backwards compatible.


That's not true I'm afraid. Microsoft broke binary compatability between
Office 2000 and XP. Most of the functions are still there but you must not use early binding - late binding must be used.

Rob.


Nov 20 '05 #16

P: n/a
> Use the Word 2000 object libraries. (Ideally, you should have Word 2000

Agreed but don't use early binding, e.g. replace

Dim MyDoc as Word.Document ' or whatever the right syntax is
MyDoc.SomeFunction

with

Dim MyDoc As Object
MyDoc.SomeFunction

This forces late binding which will work between Office 2000 and XP. I
suspect that some functions moved offets from the base of the Word library
thus breaking early binding.

It does mean unfortunately that you can't use autofill in when entering your
code which with the Word object model being so complex is a shame.

What you could do is temporarily declare MyDoc as Word.Document, get it
working and then replace it with MyDoc as Object

Cheers, Rob.
Nov 20 '05 #17

This discussion thread is closed

Replies have been disabled for this discussion.