Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Getting Data from Excel

Posted on 2000-05-14
2
Medium Priority
?
144 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 200 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

963 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