ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Need sample for reading value from and writing value to cell E53 from outside Excel (https://www.excelbanter.com/excel-programming/412675-need-sample-reading-value-writing-value-cell-e53-outside-excel.html)

Tony Bansten

Need sample for reading value from and writing value to cell E53 from outside Excel
 
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


Pegasus \(MVP\)[_2_]

Need sample for reading value from and writing value to cell E53 from outside Excel
 

"Tony Bansten" wrote in message
...
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

Try this:

Set objExcel = CreateObject ("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open("c:\Test.xls")
Set objWorksheet = objExcel.ActiveWorkbook.Worksheets(1)
iValue = objWorksheet.Cells(1, 6).Value
objWorksheet.Cells(2, 5).Value = 55




Richard Mueller [MVP]

Need sample for reading value from and writing value to cell E53 from outside Excel
 
Tony 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?


For example:
=======
Option Explicit
Dim objExcel, strExcelPath, objSheet, strValue

Set objExcel = CreateObject("Excel.Application")
strExcelPath = "c:\Scripts\aaa.xls"

' Open specified spreadsheet and select worksheet.
objExcel.WorkBooks.Open strExcelPath
Set objSheet = objExcel.ActiveWorkbook.Worksheets("ws777")

' Read value from cell in row 53, column E.
strValue = objSheet.Cells(53, 5).Value
Wscript.Echo strValue

' Assign value to cell in row 53, column E.
strValue = "This is a test, this is only a test."
objSheet.Cells(53, 5).Value = strValue

' Save workbook, close, and quit Excel.
objExcel.ActiveWorkbook.Save
objExcel.ActiveWorkbook.Close
objExcel.Application.Quit
========
I have an example VBScript program to read values from a spreadsheet linked
he

http://www.rlmueller.net/Read%20from%20Excel.htm

And another example to write value linked he

http://www.rlmueller.net/Write%20to%20Excel.htm

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--



Tom Lavedas[_2_]

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
===========

[email protected]

Need sample for reading value from and writing value to cell E53from outside Excel
 
On 16 Jun., 20:48, (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


Here is a sample VBScript to write to a specific Excel Worksheet:
http://www.scriptbox.at.tt/index.php?search=Open an Excel Workbook and
write a Value to a specific Worksheet.vbs&site=1


You can find more Excel VBS Samples he
http://www.scriptbox.at.tt/index.php...h=Excel&site=1


Bishop

Need sample for reading value from and writing value to cell E53 f
 
"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


Here is a sample VBScript to write to a specific Excel Worksheet:
http://www.scriptbox.at.tt/index.php?search=Open an Excel Workbook and write
a Value to a specific Worksheet.vbs&site=1


here you can find more VBScript Samples to work with Excel
http://www.scriptbox.at.tt/index.php...h=excel&site=1





All times are GMT +1. The time now is 10:08 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com