473,404 Members | 2,213 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Problem with Word...

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
16 1706
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
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
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
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
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
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
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
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
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
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
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
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
> 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
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
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
> 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Joan | last post by:
I am creating a word document from an asp page. I have no problems actaully creating the document and creating some tables that have data in them. I am using Response.ContentType =...
5
by: Clifford W. Racz | last post by:
Has anyone solved the issue of translating lists in Word 2003 (WordML) into xHTML? I have been trying to get the nested table code for my XSLT to work for a while now, with no way to get the...
12
by: teoryn | last post by:
I've been spending today learning python and as an exercise I've ported a program I wrote in java that unscrambles a word. Before describing the problem, here's the code: *--beginning of file--*...
11
by: Marcus Jacobs | last post by:
Dear Group I have encountered a problem with fclose and I am wondering if anyone could provide some insight about this problem to me. Currently, I am working on a small personal project that is...
5
by: John N. | last post by:
Hi All, Here I have a linked list each containing a char and is double linked. Then I have a pointer to an item in that list which is the current insertion point. In this funtion, the user...
2
by: ashmangat | last post by:
I'm trying to claculate the average number of characters per words but having some problems Every time i run this program, i get 0 as the average #include <iostream> #include <string> #include...
11
by: leiz | last post by:
Hi, I am using COM to automate Word. In the main thread of my program, I store all the Document objects from Application.Documents. In one event handler (the event generated by Word), if i get...
9
by: weidongtom | last post by:
Hi, I've written the code that follows, and I use the function add_word(), it seems to work fine *before* increase_arrays() is called that uses realloc() to allocate more memory to words. But...
9
by: david | last post by:
I will past only two segments from the code it should be enough to see what I did wrong, I think I know there I made a mistake, but how to fix it I can not tell. This why I need help from you all....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.