Word Object Problem

M

M.L.Srinivas

I have an application having refernce for 'Microsoft Word
10.0 Object Library'(compiled on Win 2000).

When I installed on any other system having Office
97...the document object is not getting activated and at
the point of opening the doc..it is either giving 'Dr.
Watson error' or it's getting closed.

The Word window is getting opened but not the document
inside.

Can anyone let me know what could be the problem?

Thanks,
M.L.Srinivas
 
J

Jezebel

If the target machine has Word 97 on it, it doesn't have the Word 10
library. Either you need to develop your code to work with Word 97 or you
need to get your client to purchase a copy of Word 2002.
 
M

M.L.Srinivas

Hi jezebel,

Thanks for your reply... When the library is in reference,
the OLB (of word 2002) file should get registered, when
the application is installed on any system...why it's not
happening? I used package and deployment wizard to create
setup package. I believe this take care of all lib. files.


M.L.Srinivas
 
J

Jezebel

Because that's a copyright OLB that won't run unless the target machine has
a licence for it. You're breaching copyright distributing it out at all.
 
J

Jonathan West

M.L.Srinivas said:
I have an application having refernce for 'Microsoft Word
10.0 Object Library'(compiled on Win 2000).

When I installed on any other system having Office
97...the document object is not getting activated and at
the point of opening the doc..it is either giving 'Dr.
Watson error' or it's getting closed.

The Word window is getting opened but not the document
inside.

Can anyone let me know what could be the problem?

If you need your program to work with multiple versions of Word, then i
would advise using late binding instead of early binding.

- Dont make a reference to Word in the References dialog
- Declare the word application object variable as being of type Object
- Assign the variable to an instance of Word using the CreateObjuect or
GetObject command
- Test thoroughly with all the versions of Word that you want to support.

You might need to have dome variations in your code depending on which
version of Word is installed on the target machine. This article shows you
how to find out.

http://www.fawcette.com/vsm/2002_06/magazine/columns/qa/default_pf.aspx
(scroll down to the section titled "Determine If Word is Installed")
 
M

M.L.Srinivas

Mr. West,

Thanks for your replay. It worked fine, but I came across
a new problem with selection object.

How to declare and use selection object in case of word
object late binding.

I tried the following methods:
Method I:
Dim sel as Object
set sel=createobject("Word.Selection")

Method II:
With out declaring the object I used
WordApp.Selection.Range (WordApp is my word object)

Both are not working in the following code:
Set myfield = WordApp.ActiveDocument.Fields.Add
(Range:=WordApp.Selection.Range, _
Type:=wdFieldDocProperty, Text:="ServiceDate
\@ ""MMMM dd, yyyy""")

P.S. : this is working when reference of word lib. is given

Please suggest me a way out and once thanks for your time

M.L.Srinivas
 
G

Guest

Mr. West,

This is the follow-up of my earlier reply to you.
The error I'm getting when i'm using
Wordapp.selection.range is 'Value out of range'.

Hope this will give you a clear picture.

Thanks,
M.L.Srinivas
 
J

Jezebel

It would probably help if you read the documentation carefully on this
before you go any further. That would clarify why

set sel=createobject("Word.Selection")

doesn't work.


Dim WordApp as object
Dim sel as object

Set WordApp = CreateObject("Word.Application")
Set sel = WordApp.Selection

(won't quite work like that because you also need to open a document and
select something; and if you're coming from VB it is always better to use
Range object rather than the selection; but you get the idea ....)
 
M

M.L.Srinivas

Mr. Jezebel,
Thanks for your time and
I request you to go thru my code completely...

Please check the following code:

With out declaring the object I used
WordApp.Selection.Range (WordApp is my word object)

Both are not working in the following code:
Set myfield = WordApp.ActiveDocument.Fields.Add
(Range:=WordApp.Selection.Range, _
Type:=wdFieldDocProperty, Text:="ServiceDate
\@ ""MMMM dd, yyyy""")

I have a document opened and at the point of insertion (at
the palce of cursor) I'm trying to insert field from VB,
which to my knowledge needs selection object.
Can you please clarify this and also suggest any
alternative code with range object for doing the same task.

Thanks,
M.L.Srinivas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top