Opening Excel from Word

B

Bill

My computer at work has Word 97 installed and therefore
have to program in Word 97, but my home computer has
Excel XP (2002) installed. I am trying to open Excel
from Word with the following code but it won't open and
debugs,

Sub Work_On_Excel_File()

Dim oXL As Excel.Application

End sub

Can anyone offer any solutions, please?

Bill
 
J

Jezebel

For early binding to work (which is what you are using) you need a project
reference to the Excel library. This is on the Tools > References list in
VBE. The problem you've got here is that to work with Excel 97, you need a
reference to Excel version 8(?) (Excel8.olb); while the XP machine will have
Excel 10+.

If you bring up the References list you should see the Excel reference
listed and marked "MISSING". Clear the missing reference, scroll down to and
select Microsoft Excel object library.

Alternatively, use late binding. This code will also work --

Dim oXL as object
Set oXL = CreateObject("Excel.Application")


That should work on either machine, since it fetches whatever is in the
registry as answering to "Excel.Application".
 

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