![]() |
Command line utility for inserting data into Excel spreadsheet
Hello,
I need a command line utility that can insert data into an Excel spreadsheet from command prompt. The syntax could be something like - insertintoxls.exe "C:\Sales reports\salesrep.xls" "129290" "Sheet1!C35" where - insertintoxls.exe is the utility itself. - "C:\Sales reports\salesrep.xls" is the complete path for the Excel spreadsheet. - 129290 is the value to be inserted. - Sheet1!C35 is the cell reference. In this example, the utility should open file salesrep.xls and insert value 129290 into cell C35 on sheet 1. Any help in this reagard would be greatly appreciated. |
Command line utility for inserting data into Excel spreadsheet
Here is a simple way of performing your task.
1) Create a .BAT file with the following line MyBat.Bat excel.exe "c:\My Folder\book1.xls This will open the workbook book1.xls 2) Create a workbook open event in the book1.xls Which will read a text file ReadFile.Txt using the text lines read open another workbook and insert the data ReadFile.txt C:\Sales reports\salesrep.xls 129290 Sheet1 C35 Private Sub Workbook_Open() Const ForReading = 1, ForWriting = 2, _ ForAppending = 3 Const TextFile = "c:\temp\Readfile.Txt" Set fs = CreateObject("Scripting.FileSystemObject") Set fin = fs.OpenTextFile(TextFile, _ ForReading, TristateFalse) BookName = fin.readline WriteData = fin.readline SheetName = fin.readline WriteRange = fin.readline fin.Close Set WriteBk = Workbooks.Open(Filename:=BookName) With WriteBk.Sheets(SheetName) .Range(WriteRange) = WriteData End With WriteBk.Close savechanges:=True Application.Quit End Sub "Satish S. Joshi" wrote: Hello, I need a command line utility that can insert data into an Excel spreadsheet from command prompt. The syntax could be something like - insertintoxls.exe "C:\Sales reports\salesrep.xls" "129290" "Sheet1!C35" where - insertintoxls.exe is the utility itself. - "C:\Sales reports\salesrep.xls" is the complete path for the Excel spreadsheet. - 129290 is the value to be inserted. - Sheet1!C35 is the cell reference. In this example, the utility should open file salesrep.xls and insert value 129290 into cell C35 on sheet 1. Any help in this reagard would be greatly appreciated. |
All times are GMT +1. The time now is 12:25 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com