?
Solved

Reading Excel Spreadsheets with Visual Basic 6

Posted on 2005-03-24
1
Medium Priority
?
268 Views
Last Modified: 2013-11-25
I'd like to be able to read information out of an Excel worksheet using Visual Basic 6.  Does anyone have any sample code that allows me to do this without buying a 3rd party package.  Also writing information to a new spreadsheet would be helpful.

Thanks
0
Comment
Question by:facole
[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
1 Comment
 
LVL 16

Accepted Solution

by:
jimbobmcgee earned 1000 total points
ID: 13622779
You wish to access an Excel worksheet from VB?  Do you wish to do it without ever having installed Excel?

If not, you can use the Excel classes, installed when Excel is installed, as follows:

      Dim oExcel, oWorkbook, oSheet, oNewSheet

      Set oExcel = CreateObject("Excel.Application")
      Set oWorkbook = oExcel.Workbooks.Open("x:\path\file.xls")
      Set oSheet =oWorkBook.Sheets("mysheetname")

      MsgBox "The content of cell B3 is: " & oSheet.Range("B3").Value

      Set oNewSheet = oWorkbook.Sheets.Add

      oNewSheet.Range("A1").Value = "This is a new sheet"

      oWorkbook.Save
      oExcel.Quit

      Set oNewSheet = Nothing
      Set oSheet = Nothing
      Set oWorkbook = Nothing
      Set oExcel = Nothing

if you want Excel functionality, without Excel, and have spare $1000, you could try Aspose (http://www.aspose.com)...

HTH

J.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…

765 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