Sign in to follow this  
Followers 0
InfraRed

$oExcel.ActiveSheet.UsedRange.Rows.Count

9 posts in this topic

Hi.

I used this for a long time:

$row=$oExcel.ActiveSheet.UsedRange.Rows.Count

But in version 3.3.12.0 (1st June, 2014) (Release) Excel UDF was re-written and this code stopped working. I see this:

"D:\Dropbox\Test.au3" (8) : ==> Variable must be of type "Object".:

Is there any solution? Thanks.

Share this post


Link to post
Share on other sites



Oh, I see, now I have to 

$oExcel1 = _Excel_Open()

before 

_Excel_BookOpen

Share this post


Link to post
Share on other sites

Now trying to put some Value into cell I see:

"C:\Program Files (x86)\AutoIt3\Include\Excel.au3" (876) : ==> Illegal text at the end of statement (one statement per line).:
Func _Excel_RangeWrite($oWorkbook, $vWorksheet, $vValue, $vRange = Default, $bValue = Default, $bForceFunc = Default)
Func _Excel_RangeWrite($oWorkbook, $vWorksheet, $vValue, $vRange = Default, $bV^ ERROR

Using 

_Excel_RangeWrite ($oExcel, $oExcel.Activesheet, 0, "F2")

Share this post


Link to post
Share on other sites

Can you please post the full script? Most of the time the error is caused somewhere else (missing quote etc.).

1 person likes this

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Here it is:

#include <Misc.au3>
#Include <File.au3>
#Include <Array.au3>
#include <Excel.au3>
#include <Math.au3>
$oExcel1 = _Excel_Open(False)
$oExcel = _Excel_BookOpen ($oExcel1,"D:\Dropbox\Gold10.xls", 0)
$row=$oExcel.ActiveSheet.UsedRange.Rows.Count
$SilvemoonA=Int(_Excel_RangeRead ($oExcel, Default , "C" & $row)/1000)
$KazzakH=Int(_Excel_RangeRead ($oExcel, Default , "E" & $row)/1000)
$DraenorH=Int(_Excel_RangeRead ($oExcel, Default , "G" & $row)/1000)
$RavencrestA=Int(_Excel_RangeRead ($oExcel, Default , "I" & $row)/1000)
$FrostmaneA=Int(_Excel_RangeRead ($oExcel, Default , "K" & $row)/1000)
$SylvanasA=Int(_Excel_RangeRead ($oExcel, Default , "M" & $row)/1000)
$RagnarosH=Int(_Excel_RangeRead ($oExcel, Default , "O" & $row)/1000)
$TwistingNetherH=Int(_Excel_RangeRead ($oExcel, Default , "Q" & $row)/1000)
_Excel_BookClose($oExcel)
$oExcel = _Excel_BookOpen ($oExcel1,"D:\Dropbox\gold_stock.xls", 0)
_Excel_RangeWrite ($oExcel, $oExcel.Activesheet, $DraenorH, "C2")
If $DraenorH>30 Then _Excel_RangeWrite ($oExcel, $oExcel.Activesheet, 0, "F2") Else _Excel_RangeWrite ($oExcel, $oExcel.Activesheet, 1, "F2")
_Excel_RangeWrite ($oExcel, $oExcel.Activesheet, $FrostmaneA, "C3")
If $FrostmaneA>30 Then _Excel_RangeWrite ($oExcel, $oExcel.Activesheet, 0, "F3") Else _Excel_RangeWrite ($oExcel, $oExcel.Activesheet, 1, "F3")
_Excel_RangeWrite ($oExcel, $oExcel.Activesheet, $KazzakH, "C4")
If $KazzakH>30 Then _Excel_RangeWrite ($oExcel, $oExcel.Activesheet, 0, "F4") Else _Excel_RangeWrite ($oExcel, $oExcel.Activesheet, 1, "F4")
_Excel_RangeWrite ($oExcel, $oExcel.Activesheet, $RagnarosH, "C5")
If $RagnarosH>30 Then _Excel_RangeWrite ($oExcel, $oExcel.Activesheet, 0, "F5") Else _Excel_RangeWrite ($oExcel, $oExcel.Activesheet, 1, "F5")
_Excel_RangeWrite ($oExcel, $oExcel.Activesheet, $RavencrestA, "C6")
If $RavencrestA>30 Then _Excel_RangeWrite ($oExcel, $oExcel.Activesheet, 0, "F6") Else _Excel_RangeWrite ($oExcel, $oExcel.Activesheet, 1, "F6")
_Excel_RangeWrite ($oExcel, $oExcel.Activesheet, $SilvemoonA, "C7")
If $SilvemoonA>30 Then _Excel_RangeWrite ($oExcel, $oExcel.Activesheet, 0, "F7") Else _Excel_RangeWrite ($oExcel, $oExcel.Activesheet, 1, "F7")
_Excel_RangeWrite ($oExcel, $oExcel.Activesheet, $SylvanasA, "C8")
If $SylvanasA>30 Then _Excel_RangeWrite ($oExcel, $oExcel.Activesheet, 0, "F8") Else _Excel_RangeWrite ($oExcel, $oExcel.Activesheet, 1,"F8")
_Excel_RangeWrite ($oExcel, $oExcel.Activesheet, $TwistingNetherH, "C9")
If $TwistingNetherH>30 Then _Excel_RangeWrite ($oExcel, $oExcel.Activesheet, 0, "F9") Else _Excel_RangeWrite ($oExcel, $oExcel.Activesheet, 1, "F9")
_Excel_BookClose($oExcel)
_Excel_Close($oExcel1, True, True)

Share this post


Link to post
Share on other sites

You can't have If / Then / Else on the same line.

1 person likes this

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

But it worked before, and still working in older versions.. Ok, I'll try

Edited by InfraRed

Share this post


Link to post
Share on other sites

Omg, really, it works! Thanks a lot.

Share this post


Link to post
Share on other sites

If you select "Syntax Check" in SciTE you should get error messages showing you where to change your script.

1 person likes this

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0