Page 1 of 1 1
Topic Options
#188147 - 2008-06-11 01:07 PM readexcel2 error
Saleem Offline
Hey THIS is FUN
*

Registered: 2001-04-11
Posts: 280
Loc: UAE
Hi there

this is my main script

 PHP:
Break on $domain = GetObject("WinNT://" + @LDomain) $domain.filter="User","" Call "d:\kix\udf\readexcel.udf" $range=readexcel2('D:\security\AD.xls',1,-1,-1,1,1) For $counter=0 to Ubound($range) $empid=$range[$counter,0] For Each $user In $domain If $user.name=$empid ? $user.Name ? $user.userAccountControl EndIf ;Sleep 0.2 Next Next



I am geting folowing error from this function


ERROR : error in expression!
Script: d:\kix\udf\readexcel2.udf
Line : 157

on line number 157
$ReadExcel2[$!-1,$_-1]=$.sheets($1).cells($!,$_).value

I am using kix ver 4.60.0.0
Office 2003
_________________________
“I’ll not change you unless you don’t have intention to change yourself” --H:Quran

Top
#188153 - 2008-06-11 02:01 PM Re: readexcel2 error [Re: Saleem]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
Can you output the values of $! and $_ before executing to verify that they are valid?

You're using them to index an array, and if they are zero or negative, you'll get an invalid expression when you reduce them by 1, as you are doing. The problem may actually be earlier in your code, causing these values to be invalid.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#188174 - 2008-06-12 05:50 AM Re: readexcel2 error [Re: Glenn Barnas]
Saleem Offline
Hey THIS is FUN
*

Registered: 2001-04-11
Posts: 280
Loc: UAE
when I display $! and $_ it is giving some values, If I disable
 PHP:
;$ReadExcel2[$!-1,$_-1]=$.sheets($1).cells($!,$_).value
this I am getting -1

even I change my first code to
 PHP:
$range=readexcel2('D:\security\AD.xls',,-1,3,) if @error "error occured: @serror (@error)" else For $counter=0 to Ubound($range,2) ? "name: " $range[$counter,0] ? Next


Still same error !!!
_________________________
“I’ll not change you unless you don’t have intention to change yourself” --H:Quran

Top
#188182 - 2008-06-12 12:35 PM Re: readexcel2 error [Re: Saleem]
Saleem Offline
Hey THIS is FUN
*

Registered: 2001-04-11
Posts: 280
Loc: UAE
Please help me....
_________________________
“I’ll not change you unless you don’t have intention to change yourself” --H:Quran

Top
#188192 - 2008-06-12 02:52 PM Re: readexcel2 error [Re: Saleem]
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Did you try using version 4.53 ? 4.60 has a few COM issues.
Top
#188215 - 2008-06-13 10:24 PM Re: readexcel2 error [Re: Shawn]
Saleem Offline
Hey THIS is FUN
*

Registered: 2001-04-11
Posts: 280
Loc: UAE
Thanx Shawn

I'll try and let u know on sunday.. I am out of office now
_________________________
“I’ll not change you unless you don’t have intention to change yourself” --H:Quran

Top
#188217 - 2008-06-15 06:02 AM Re: readexcel2 error [Re: Saleem]
Saleem Offline
Hey THIS is FUN
*

Registered: 2001-04-11
Posts: 280
Loc: UAE
I am getting same error...
_________________________
“I’ll not change you unless you don’t have intention to change yourself” --H:Quran

Top
#188229 - 2008-06-16 10:02 PM Re: readexcel2 error [Re: Saleem]
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Fixed..

Original example is missing an endif..

 Code:
 CLS
 BREAK ON
 $range=readexcel2(@scriptdir+'\AD.xls',,-1,3)
 IF @error
       "error occured: @serror (@error)"
 ELSE
       FOR $counter=0 TO ubound($range,2)
             ? "first name: " $range[$counter,0]
             ? "last name: " $range[0,1]
             ? "login: " $range[0,2]
             ?
             SLEEP 0.2
       NEXT
 ENDIF
 ?'Script is complete'
 GET $


In the UDF, locate the line:
 Code:
 dim $_[$2-1,$3-1]


Replace with:
 Code:
 redim $_[$2-1,$3-1]


Your code should run fine then..

I am sending a PM to Lonk to fix the original UDF..

Thanks,

Kent


Edited by Kdyer (2008-06-16 10:03 PM)
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#188243 - 2008-06-17 05:47 AM Re: readexcel2 error [Re: Kdyer]
Saleem Offline
Hey THIS is FUN
*

Registered: 2001-04-11
Posts: 280
Loc: UAE
Man.........

U ROCK........

it's working now... wonder no one has this problem up to now, I am sure this is one of the heavily used function.
_________________________
“I’ll not change you unless you don’t have intention to change yourself” --H:Quran

Top
#188301 - 2008-06-20 03:16 PM Re: readexcel2 error [Re: Saleem]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
ok, the udf has been changed.
_________________________
!

download KiXnet

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (mole) and 1300 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.061 seconds in which 0.025 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org