Solved

Opening Excel Spreadsheet from Word

Posted on 2013-02-05
3
434 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

724 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