Solved

Opening Excel Spreadsheet from Word

Posted on 2013-02-05
3
395 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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

It is often necessary in this forum and others to illustrate Word fields as text with the field delimiters replaced with the curly brackets that the delimiters resemble when field codes are being displayed on the document. This means that the text c…
I'm writing to share my clumsy experience in using this elegant tool so you can avoid every stupid mistake I made. (I leave it to the authorities to decide if this deserves a place in the Knowledge archives.)  Now that I am on the other side of my l…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
Office 365 is currently available in five editions. Three of them are for business use: Office 365 Business Essentials, Office 365 Business, and Office 365 Business Premium. Two of them are for home/personal use: Office 365 Home and Office 365 Perso…

706 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now