?
Solved

accessing an excel spreadsheet using VB

Posted on 1999-11-04
2
Medium Priority
?
179 Views
Last Modified: 2012-05-04
I want to be able to open and access the information in various cells in an Excel spreadsheet that I have. How do I go about this? Do I use the "Open ...For Input.." command? How do I get to a specific cell?
Thanks.
0
Comment
Question by:JMaher
2 Comments
 

Accepted Solution

by:
SwordSaint earned 400 total points
ID: 2185178
Dim xlApp As excel.Application
Dim xlBook As excel.Workbook
Dim xlSheet As excel.Worksheet

Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Add(filepath)
Set xlSheet = xlBook.Worksheets(1)
xlApp.Visible = True
Dim a
a = xlSheet.Cells(1, 1).Value
0
 

Author Comment

by:JMaher
ID: 2190152
Thats great. Thanks. While I was waiting for someone to answer, I was playing with VisData (vb5) to try to open the worksheet that way. I was able to open it, but not able to use a SELECT query on it. VisData (and the Data control in my test app) said the name of the table was Database$ (even in the Query Builder), but when I wrote "SELECT * FROM Database$" I kept getting an error saying that the error in FROM clause. I have tried everything I can think of in the FROM clause, but cannot open the darn thing. Any other ideas?
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

601 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