Hi,

I have written a script that reads value from Excel & "should terminate"
when blank cell is encountered.
However, even the script that is posted on the site does not get terminated
"immediately" when the blank cell or row is encountered.

It terminates only after the blank row is passed for one time.

How can i make the script terminate "immediately" when it encounters blank
row. It should not read that row at all.

Following is a sample script from the site :

=========
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open _
("C:\Scripts\New_users.xls")
intRow = 2
Do Until objExcel.Cells(intRow,1).Value = ""
Wscript.Echo "CN: " & objExcel.Cells(intRow, 1).Value
Wscript.Echo "sAMAccountName: " & objExcel.Cells(intRow, 2).Value
Wscript.Echo "GivenName: " & objExcel.Cells(intRow, 3).Value
Wscript.Echo "LastName: " & objExcel.Cells(intRow, 4).Value
intRow = intRow + 1
Loop
objExcel.Quit

=============

Any help on terminating immediately after it encounters blank row would be
much appreciated.


thanks in advance ...

Re: Excel scripting by noone

noone
Sun Oct 22 15:18:33 CDT 2006

Il giorno Fri, 13 Oct 2006 01:24:01 -0700, =?Utf-8?B?SmFjayBEb3Jzb24=?=
<JackDorson@discussions.microsoft.com> ha scritto:
>Set objExcel = CreateObject("Excel.Application")
>Set objWorkbook = objExcel.Workbooks.Open _
> ("C:\Scripts\New_users.xls")
>intRow = 2
>Do Until objExcel.Cells(intRow,1).Value = ""
> Wscript.Echo "CN: " & objExcel.Cells(intRow, 1).Value
> Wscript.Echo "sAMAccountName: " & objExcel.Cells(intRow, 2).Value
> Wscript.Echo "GivenName: " & objExcel.Cells(intRow, 3).Value
> Wscript.Echo "LastName: " & objExcel.Cells(intRow, 4).Value
> intRow = intRow + 1
>Loop
>objExcel.Quit

if you are sure row 2 is not empty you can move the until clause to the end of the loop.
It processes row 2, then adds 1 and checks row 3. If row 3 is not empty repeats the loop,
otherwise it ends.
Giovanni.
--
Giovanni Cenati (Aosta, Italy)
Write to user "Reventlov" and domain at katamail com
http://digilander.libero.it/Cenati (Esempi e programmi in VbScript)
--