Solved

Opening Excel Spreadsheet from Word

Posted on 2013-02-05
3
416 Views
Last Modified: 2013-02-05
I wrote some VB to open up and specific Excel spreadsheet in office 2003.  The code i used to do this was:

Set oExcel = CreateObject("Excel.Application")
Set oWB = oExcel.Workbooks.Open(SheetLocation)

Open in new window


This worked fine.

We have now moved to office 2010 and the above no longer works.  I have added the Excel 14.0 object library reference but the error message i get is:

"Unable to get the Open Property of the workbook class"

It errors on "Set oWB = oExcel.Workbooks.Open(SheetLocation)"

Any ideas how to open up the spreadsheet in the correct way for 2010?

Thanks
0
Comment
Question by:jdc1944
  • 2
3 Comments
 
LVL 16

Accepted Solution

by:
terencino earned 500 total points
ID: 38854368
This works on 2010 and 2013.
Hope this helps
...Terry

Dim oExcel As Object, oWB As Object
SheetLocation = "C:\Test\Book1.xlsx"
Set oExcel = CreateObject("Excel.Application")
oExcel.Visible = True
Set oWB = oExcel.Workbooks.Open(SheetLocation)

Open in new window

0
 
LVL 2

Author Comment

by:jdc1944
ID: 38854408
Thanks for that.  

Using the above I realized that the issue was the SheetLocation variable which was storing the wrong path.  Whereas in word this normally creates an error that the file could not found, in excel it comes with the above error message which to me doesn't relate.
0
 
LVL 2

Author Closing Comment

by:jdc1944
ID: 38854412
Led me to find the issue was with a variable.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A few years ago I was very much a beginner at VBA, and that very much remains the case today.  I'll do my best to explain things as I go in the hope that other beginners can follow.  If you just want to check out a tool that creates a Select Case fu…
Microsoft Word is a program we have all encountered at some point, but very few of us have dug deep into its full scope of features, let alone customized it to suit our needs. Luckily making the ribbon (aka toolbar, first introduced in Word 2007) wo…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question