Computer Hope

Software => Computer programming => Topic started by: Tripti on April 20, 2008, 01:08:00 PM

Title: VB Script help
Post by: Tripti on April 20, 2008, 01:08:00 PM
Hello,

If we want to enter some data in a text file using VBScript we use:

with objectname

.writeline "abcd"
.writeline "efgh"


but what if we want to make entries in database, say an excel sheeet?

what is the syntax for that?

Please help.

 :)Thankyou.
Title: Re: VB Script help
Post by: Sidewinder on April 20, 2008, 06:54:50 PM
Excel spreadsheets can be accessed either through the Excel object (see snippet) or with an ADO connection.

Code: [Select]
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Add()
xlApp.Visible = True
xlApp.Cells(1, 1).Value = "Test value"
xlBook.SaveAs "c:\scripts\foobar.xls"
xlApp.Quit

Where is the data coming from? Each cell: cells(1,1) is addressed with row, column coordinates. By using variables for the coordinates, it should be easy enough to read a file and place the data in the spreadsheet.

 8)