Solved

Urgent, pls help - Open Excel & get cell values

Posted on 2000-05-03
2
202 Views
Last Modified: 2013-12-18
Hi,
I need some sample coding on how to open an existing MS Excel file, and get the cell value out to a variable.

Pls help if you have sample on this...
It's very urgent. I have to complete it by tomorrow.
Thanks very much!
0
Comment
Question by:kspuea
2 Comments
 
LVL 3

Accepted Solution

by:
Simon_Hendry earned 80 total points
ID: 2772819
Here is a function to get the cell value from the specified file

Function GetCellValue(CellName As String,FileName As String) As String

     Dim RTString As String

     Set Chart = CreateObject("Excel.Sheet")
     
     Set ExcelApp = Chart.Application.Application
     
     ExcelApp.Visible = False
     
     Call ExcelApp.WorkBooks.Add(FileName)
     
     ExcelApp.Range(CellName).Select

     RTString = Cstr(ExcelApp.ActiveCell.Value)
     
     ExcelApp.Quit

     GetCellValue = RTString

End Function


This can be called thus::

Data = GetCellValue("C3","book3.xls")

0
 

Author Comment

by:kspuea
ID: 2772888
Thanks a lot, Simon!!

But I still don't quite understand why you want to write the following lines:

Set ExcelApp = Chart.Application.Application
     
ExcelApp.Visible = False
     
Call ExcelApp.WorkBooks.Add(FileName)

Is it opening MS Excel application and make it invisible?
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

For Desktop Techs: How to retain a user's Notes configuration data when swapping out the end user's computer. (Assuming that you are not upgrading to a completely different version of Notes client) All you need to do is: 1) install Notes o…
  In today’s Arena we can’t imagine our lives without Internet as we are highly used to of it. If we consider our life style just for only 2 min we found that face to face communication is swapped by e-communication.  Every Where from Works place to…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

831 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