Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Kam Kam is offline
external usenet poster
 
Posts: 57
Default Help with calling word reference from excel vba

I have vba code in excel that calls on some functions of Word.

I am using Office 2003 but my users are using either 2002 or 2003.

When I add the reference from the vba editor, I am able to choose:
Microsoft Word 11.0 Object Library (from my machine)

But when one of my users is using Office 2002 it needs a call to ver 10.0 of
the object Library.

How do I set up a reference to work on both 10.0 and 11.0? I do not have an
option to choose Microsoft Word 10.0 Object Library from mine since I am
running 2003 (11.0)

Any ideas on how I can set this up?

Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Help with calling word reference from excel vba

By choosing Word 11 as your reference you are doing something called early
binding (creating your reference at design time). You would be better off
creating your reference at run time. This is known as late binding. You loose
the intellisence but you gain the flexibility... Since you have already
written your code all you need to do is to change your objects from Word to
Object and remove your reference to the work application in the VBE. Use code
similar to what is posted below to create the Word app.

Sub test()
Dim appWord As Object

Set appWord = CreateObject("Word.Application")
appWord.Visible = True
End Sub


--
HTH...

Jim Thomlinson


"KAM" wrote:

I have vba code in excel that calls on some functions of Word.

I am using Office 2003 but my users are using either 2002 or 2003.

When I add the reference from the vba editor, I am able to choose:
Microsoft Word 11.0 Object Library (from my machine)

But when one of my users is using Office 2002 it needs a call to ver 10.0 of
the object Library.

How do I set up a reference to work on both 10.0 and 11.0? I do not have an
option to choose Microsoft Word 10.0 Object Library from mine since I am
running 2003 (11.0)

Any ideas on how I can set this up?

Thanks!

  #3   Report Post  
Posted to microsoft.public.excel.programming
Kam Kam is offline
external usenet poster
 
Posts: 57
Default Help with calling word reference from excel vba

Thank you for that explanation!

If I don't really need Word open (I am only using a function available in
Word) then I would just create the object and not set it to visible as below?

Dim appWord As Object
Set appWord = CreateObject("Word.Application")
code here
Set appWord = Nothing

Is this how I would do it?

Thanks!

"Jim Thomlinson" wrote:

By choosing Word 11 as your reference you are doing something called early
binding (creating your reference at design time). You would be better off
creating your reference at run time. This is known as late binding. You loose
the intellisence but you gain the flexibility... Since you have already
written your code all you need to do is to change your objects from Word to
Object and remove your reference to the work application in the VBE. Use code
similar to what is posted below to create the Word app.

Sub test()
Dim appWord As Object

Set appWord = CreateObject("Word.Application")
appWord.Visible = True
End Sub


--
HTH...

Jim Thomlinson


"KAM" wrote:

I have vba code in excel that calls on some functions of Word.

I am using Office 2003 but my users are using either 2002 or 2003.

When I add the reference from the vba editor, I am able to choose:
Microsoft Word 11.0 Object Library (from my machine)

But when one of my users is using Office 2002 it needs a call to ver 10.0 of
the object Library.

How do I set up a reference to work on both 10.0 and 11.0? I do not have an
option to choose Microsoft Word 10.0 Object Library from mine since I am
running 2003 (11.0)

Any ideas on how I can set this up?

Thanks!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Help with calling word reference from excel vba

Yup... Just make sure you close the object before setting it to nothing.
Otherwise you will end up with an orphaned instance of Word running that is
not visible.
--
HTH...

Jim Thomlinson


"KAM" wrote:

Thank you for that explanation!

If I don't really need Word open (I am only using a function available in
Word) then I would just create the object and not set it to visible as below?

Dim appWord As Object
Set appWord = CreateObject("Word.Application")
code here
Set appWord = Nothing

Is this how I would do it?

Thanks!

"Jim Thomlinson" wrote:

By choosing Word 11 as your reference you are doing something called early
binding (creating your reference at design time). You would be better off
creating your reference at run time. This is known as late binding. You loose
the intellisence but you gain the flexibility... Since you have already
written your code all you need to do is to change your objects from Word to
Object and remove your reference to the work application in the VBE. Use code
similar to what is posted below to create the Word app.

Sub test()
Dim appWord As Object

Set appWord = CreateObject("Word.Application")
appWord.Visible = True
End Sub


--
HTH...

Jim Thomlinson


"KAM" wrote:

I have vba code in excel that calls on some functions of Word.

I am using Office 2003 but my users are using either 2002 or 2003.

When I add the reference from the vba editor, I am able to choose:
Microsoft Word 11.0 Object Library (from my machine)

But when one of my users is using Office 2002 it needs a call to ver 10.0 of
the object Library.

How do I set up a reference to work on both 10.0 and 11.0? I do not have an
option to choose Microsoft Word 10.0 Object Library from mine since I am
running 2003 (11.0)

Any ideas on how I can set this up?

Thanks!

  #5   Report Post  
Posted to microsoft.public.excel.programming
Kam Kam is offline
external usenet poster
 
Posts: 57
Default Help with calling word reference from excel vba

Got it working now! Thanks so much.

"Jim Thomlinson" wrote:

Yup... Just make sure you close the object before setting it to nothing.
Otherwise you will end up with an orphaned instance of Word running that is
not visible.
--
HTH...

Jim Thomlinson


"KAM" wrote:

Thank you for that explanation!

If I don't really need Word open (I am only using a function available in
Word) then I would just create the object and not set it to visible as below?

Dim appWord As Object
Set appWord = CreateObject("Word.Application")
code here
Set appWord = Nothing

Is this how I would do it?

Thanks!

"Jim Thomlinson" wrote:

By choosing Word 11 as your reference you are doing something called early
binding (creating your reference at design time). You would be better off
creating your reference at run time. This is known as late binding. You loose
the intellisence but you gain the flexibility... Since you have already
written your code all you need to do is to change your objects from Word to
Object and remove your reference to the work application in the VBE. Use code
similar to what is posted below to create the Word app.

Sub test()
Dim appWord As Object

Set appWord = CreateObject("Word.Application")
appWord.Visible = True
End Sub


--
HTH...

Jim Thomlinson


"KAM" wrote:

I have vba code in excel that calls on some functions of Word.

I am using Office 2003 but my users are using either 2002 or 2003.

When I add the reference from the vba editor, I am able to choose:
Microsoft Word 11.0 Object Library (from my machine)

But when one of my users is using Office 2002 it needs a call to ver 10.0 of
the object Library.

How do I set up a reference to work on both 10.0 and 11.0? I do not have an
option to choose Microsoft Word 10.0 Object Library from mine since I am
running 2003 (11.0)

Any ideas on how I can set this up?

Thanks!



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Help with calling word reference from excel vba

One thing I forgot to mention is that when you use late binding you can not
use any of the built in constants of Word. You need to traslate those to the
actual numerical values they represent...
--
HTH...

Jim Thomlinson


"KAM" wrote:

Got it working now! Thanks so much.

"Jim Thomlinson" wrote:

Yup... Just make sure you close the object before setting it to nothing.
Otherwise you will end up with an orphaned instance of Word running that is
not visible.
--
HTH...

Jim Thomlinson


"KAM" wrote:

Thank you for that explanation!

If I don't really need Word open (I am only using a function available in
Word) then I would just create the object and not set it to visible as below?

Dim appWord As Object
Set appWord = CreateObject("Word.Application")
code here
Set appWord = Nothing

Is this how I would do it?

Thanks!

"Jim Thomlinson" wrote:

By choosing Word 11 as your reference you are doing something called early
binding (creating your reference at design time). You would be better off
creating your reference at run time. This is known as late binding. You loose
the intellisence but you gain the flexibility... Since you have already
written your code all you need to do is to change your objects from Word to
Object and remove your reference to the work application in the VBE. Use code
similar to what is posted below to create the Word app.

Sub test()
Dim appWord As Object

Set appWord = CreateObject("Word.Application")
appWord.Visible = True
End Sub


--
HTH...

Jim Thomlinson


"KAM" wrote:

I have vba code in excel that calls on some functions of Word.

I am using Office 2003 but my users are using either 2002 or 2003.

When I add the reference from the vba editor, I am able to choose:
Microsoft Word 11.0 Object Library (from my machine)

But when one of my users is using Office 2002 it needs a call to ver 10.0 of
the object Library.

How do I set up a reference to work on both 10.0 and 11.0? I do not have an
option to choose Microsoft Word 10.0 Object Library from mine since I am
running 2003 (11.0)

Any ideas on how I can set this up?

Thanks!

  #7   Report Post  
Posted to microsoft.public.excel.programming
Kam Kam is offline
external usenet poster
 
Posts: 57
Default Help with calling word reference from excel vba

OK, makes sense...but part of my code:

With appWd.Selection
.Tables(1).Select
.Rows.HeightRule = wdRowHeightAtLeast
.Rows.Height = InchesToPoints(0.25)
.HomeKey Unit:=wdStory
End With


It is only giving an error on the .rows.height = inchestopoints(0.25). I
would have thought the other items set to wd constants would have erred...Am
I missing something?

"Jim Thomlinson" wrote:

One thing I forgot to mention is that when you use late binding you can not
use any of the built in constants of Word. You need to traslate those to the
actual numerical values they represent...
--
HTH...

Jim Thomlinson


"KAM" wrote:

Got it working now! Thanks so much.

"Jim Thomlinson" wrote:

Yup... Just make sure you close the object before setting it to nothing.
Otherwise you will end up with an orphaned instance of Word running that is
not visible.
--
HTH...

Jim Thomlinson


"KAM" wrote:

Thank you for that explanation!

If I don't really need Word open (I am only using a function available in
Word) then I would just create the object and not set it to visible as below?

Dim appWord As Object
Set appWord = CreateObject("Word.Application")
code here
Set appWord = Nothing

Is this how I would do it?

Thanks!

"Jim Thomlinson" wrote:

By choosing Word 11 as your reference you are doing something called early
binding (creating your reference at design time). You would be better off
creating your reference at run time. This is known as late binding. You loose
the intellisence but you gain the flexibility... Since you have already
written your code all you need to do is to change your objects from Word to
Object and remove your reference to the work application in the VBE. Use code
similar to what is posted below to create the Word app.

Sub test()
Dim appWord As Object

Set appWord = CreateObject("Word.Application")
appWord.Visible = True
End Sub


--
HTH...

Jim Thomlinson


"KAM" wrote:

I have vba code in excel that calls on some functions of Word.

I am using Office 2003 but my users are using either 2002 or 2003.

When I add the reference from the vba editor, I am able to choose:
Microsoft Word 11.0 Object Library (from my machine)

But when one of my users is using Office 2002 it needs a call to ver 10.0 of
the object Library.

How do I set up a reference to work on both 10.0 and 11.0? I do not have an
option to choose Microsoft Word 10.0 Object Library from mine since I am
running 2003 (11.0)

Any ideas on how I can set this up?

Thanks!

  #8   Report Post  
Posted to microsoft.public.excel.programming
Kam Kam is offline
external usenet poster
 
Posts: 57
Default Help with calling word reference from excel vba

I have now switched all my constants to numbers and everything seems to
working OK now.

Thanks so much for your help!!

"Jim Thomlinson" wrote:

One thing I forgot to mention is that when you use late binding you can not
use any of the built in constants of Word. You need to traslate those to the
actual numerical values they represent...
--
HTH...

Jim Thomlinson


"KAM" wrote:

Got it working now! Thanks so much.

"Jim Thomlinson" wrote:

Yup... Just make sure you close the object before setting it to nothing.
Otherwise you will end up with an orphaned instance of Word running that is
not visible.
--
HTH...

Jim Thomlinson


"KAM" wrote:

Thank you for that explanation!

If I don't really need Word open (I am only using a function available in
Word) then I would just create the object and not set it to visible as below?

Dim appWord As Object
Set appWord = CreateObject("Word.Application")
code here
Set appWord = Nothing

Is this how I would do it?

Thanks!

"Jim Thomlinson" wrote:

By choosing Word 11 as your reference you are doing something called early
binding (creating your reference at design time). You would be better off
creating your reference at run time. This is known as late binding. You loose
the intellisence but you gain the flexibility... Since you have already
written your code all you need to do is to change your objects from Word to
Object and remove your reference to the work application in the VBE. Use code
similar to what is posted below to create the Word app.

Sub test()
Dim appWord As Object

Set appWord = CreateObject("Word.Application")
appWord.Visible = True
End Sub


--
HTH...

Jim Thomlinson


"KAM" wrote:

I have vba code in excel that calls on some functions of Word.

I am using Office 2003 but my users are using either 2002 or 2003.

When I add the reference from the vba editor, I am able to choose:
Microsoft Word 11.0 Object Library (from my machine)

But when one of my users is using Office 2002 it needs a call to ver 10.0 of
the object Library.

How do I set up a reference to work on both 10.0 and 11.0? I do not have an
option to choose Microsoft Word 10.0 Object Library from mine since I am
running 2003 (11.0)

Any ideas on how I can set this up?

Thanks!

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Help using/calling a Reference Trip[_3_] Excel Programming 2 January 9th 06 09:51 AM
Need Help using/calling a Reference Trip[_3_] Excel Programming 0 January 9th 06 03:23 AM
Calling Excel from Word with parameters DoctorG Excel Discussion (Misc queries) 4 July 12th 05 07:53 AM
Calling Word function from within Excel Ed[_9_] Excel Programming 1 September 17th 03 11:47 PM
calling word Heiko Excel Programming 0 July 9th 03 06:32 AM


All times are GMT +1. The time now is 08:44 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"