View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Lavedas[_2_] Tom Lavedas[_2_] is offline
external usenet poster
 
Posts: 7
Default Need sample for reading value from and writing value to cell E53from outside Excel

On Jun 16, 2:48 pm, (Tony Bansten) wrote:
As fas as I heard I can write to Excel cell e.g. E53 from outside with VBS.

How could such a code look like?

Assume I have an Excel file aaa.xls and a worksheet "ws777" inside:
How can I wread and write to this cell?

Tony


Example:

sPath = "C:\Documents and Settings\username\My Documents\Someplace\"
sExcelName = "aaa.xls"

with CreateObject("Excel.Application")
.Workbooks.Open sPath & sExcelName
.ActiveWorkbook.Worksheets("ws777").Activate
sResult = .Range("E53").Value
.Quit
end with
wsh.echo "E53 =", sResult

Tom Lavedas
===========