JenMaughan

Excel_RangeRead

4 posts in this topic

Hi

I know this must be a simple issue, I just don't know the answer - I've tried all variations I can think of. 

 

 I need to read to read cell range A:Q on a SPECIFIED WORKSHEET - this won't be the default open sheet that it is saved to.   Let's say, I need it to open to Parabolas - which is the Title of worksheet 2.   What it does now:  Opens to different worksheet

 

Local $oExcel = _Excel_Open()

Local $sWorkbook = @ScriptDir & "\MathClassExamples.xls"
Local $oWorkbook = _Excel_BookOpen($oExcel, $sWorkbook)

Local $aResult = _Excel_RangeRead($oWorkbook, 2, $oWorkbook.ActiveSheet.Usedrange.Columns("A:Q"), 2)


_ArrayDisplay($aResult, "Parabolas Columns A through Q")

 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I did a reproducer script/ test and I found that if you save the workbook with tab 2 active it works.  If another tab is active when you save - it does not.   I think the problem may be with the range. In this case an object is being passed as the range and it overrides the second parameter.  Therefore, "activseheet" will go to whatever the book was saved under last - even if the 2nd parameter says something different because that is the activesheet when it opens.

If you if you modify the range object from the example in the help file to this:

$oWorkbook.Worksheets.Item(2).Usedrange.Columns("A:Q")

It seems to work.

@JenMaughan please try that snippet as your third parameter. It should ignore the second parameter and produce the result.

@waterPerhaps you could add a note in the help file suggesting the second parameter will be overridden by a range object?

Edited by Jfish

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Or

Local $aResult = _Excel_RangeRead($oWorkbook, Default, $oWorkbook.Worksheets("Parabolas").Usedrange.Columns("A:Q"), 2)

If parameter 3 accesses another worksheet then specified in parameter 2 then parameter 2 will be ignored.

Edited by water
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

I have added a remark to the help file.
I'm still unsure if an additional example in the help file is needed.


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