PC Review


Reply
Thread Tools Rate Thread

Command line utility for inserting data into Excel spreadsheet

 
 
Satish S. Joshi
Guest
Posts: n/a
 
      15th Dec 2008
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.


 
Reply With Quote
 
 
 
 
Joel
Guest
Posts: n/a
 
      15th Dec 2008
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.
>
>
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Inserting data into Word document by a range of dates from Excel spreadsheet Gordon Microsoft Word New Users 3 29th Jul 2008 08:22 PM
Inserting data into Word document by a range of dates from Excel spreadsheet Gordon Microsoft Excel New Users 3 29th Jul 2008 08:22 PM
I want to select every 10th line of data in an excel spreadsheet? Matloter Microsoft Excel Misc 3 6th Dec 2007 10:33 PM
Command line utility to list processes with the "command line that was used to start the process" flahmeshess Microsoft Windows 2000 5 12th Oct 2006 02:46 AM
Inserting data from Access to an EXCEL spreadsheet Marilyn Microsoft Access VBA Modules 1 23rd Jul 2003 03:27 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:55 PM.