Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: VB Script help  (Read 2944 times)

0 Members and 1 Guest are viewing this topic.

Tripti

    Topic Starter


    Rookie

    VB Script help
    « 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.

    Sidewinder



      Guru

      Thanked: 139
    • Experience: Familiar
    • OS: Windows 10
    Re: VB Script help
    « Reply #1 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)
    The true sign of intelligence is not knowledge but imagination.

    -- Albert Einstein