Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Need Help using/calling a Reference | Excel Programming | |||
Need Help using/calling a Reference | Excel Programming | |||
Calling Excel from Word with parameters | Excel Discussion (Misc queries) | |||
Calling Word function from within Excel | Excel Programming | |||
calling word | Excel Programming |