View Single Post
  #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!