Solved

Getting Data from Excel

Posted on 2000-05-14
2
132 Views
Last Modified: 2010-05-02
I wish to import data from a named cell
in Excel 2000.

Say the cell is A1

I dont wish to open Excel only take the number stored in the Cell and use it in my VB Program

I am a beginner using VB 6
0
Comment
Question by:kennys
2 Comments
 
LVL 14

Accepted Solution

by:
wsh2 earned 50 total points
ID: 2808419
Try this..
------------------------------------

   Dim xlsApp As Object
   Set xlsApp = CreateObject("excel.application")
   xlsApp.Visible = False
   xlsApp.workbooks.Open "c:\MyPath\MyFile.XLS"

   msgbox xlApp.Cells(1, 1)

------------------------------------

0
 
LVL 17

Expert Comment

by:calacuccia
ID: 2808422
Hi Kennys,

You can't get an Excel sheet cell value without opening it.

Try this module:

Sub ReplaceHTMLcharacters()
Dim xl As Object
Dim MyVar As String
Set xl = CreateObject("Excel.Application")
xl.Visible = False
xl.Workbooks.Open "C:\Mijn documenten\Computers Question_bestanden\GoodChartMarks.xls"
Set wb = xl.Workbooks("GoodChartMarks.xls")
MyVar = wb.Sheets("Sheet1").Cells(1, 1).Value
xl.Application.Quit
MsgBox (MyVar)
End Sub

Change path and workbook name, and sheet name to your needs and test it.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

757 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

19 Experts available now in Live!

Get 1:1 Help Now