Jump to content

Excel_RangeRead


Recommended Posts

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")

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...