Danyfirex

Error Excel RangeRead (Solved)

6 posts in this topic

#1 ·  Posted (edited)

Hello. I was trying to automate some excel task. But I can figure me out why I cant read this excel sheet.

#include <Array.au3>
#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an example workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookOpen($oExcel, "Test.xlsx")
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example", "Error opening workbook '" & @ScriptDir & "\Extras\_Excel1.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Read the formulas of a cell range on sheet 2 of the specified workbook
; *****************************************************************************

Local $aResult = _Excel_RangeRead($oWorkbook)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example 2", "Error reading from workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example 2", "Data successfully read." & @CRLF & "Please click 'OK' to display the formulas of cells A1:C1 of sheet 2.")
_ArrayDisplay($aResult, "Excel UDF: _Excel_RangeRead Example 2 - Cells A1:C1 of sheet 2")

I got Error.

Excel file. Removed 

Saludos

 

Edited by Danyfirex
Solved

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I got Error.

Can you share exactly what the error is? Might help us a bit. The code runs fine for me, as long as I change the path:

#include <Array.au3>
#include <Excel.au3>
#include <MsgBoxConstants.au3>


Local $oExcel = _Excel_Open()
Local $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\Test.xlsx", Default, Default, 2)
Local $aResult = _Excel_RangeRead($oWorkbook)
    _ArrayDisplay($aResult, "Excel UDF: _Excel_RangeRead Example 2 - Cells A1:C1 of sheet 2")

Edit: I should specify, I put in 2 because you stated you're trying to read the formulas of a cell range. Also, your text in the _Arraydisplay does not match your call to _Excel_RangeRead, you're reading in the whole sheet, not A1:C1. Wasn't sure which you were truly after.

Edited by JLogan3o13
1 person likes this

When you're dead, you don't know you're dead - it's only difficult for those that know you. It's the same way when you're stupid...

My Scripts: SCCM UDFInclude Source with Compiled Script, Windows Firewall UDF

Share this post


Link to post
Share on other sites

I feel like idiot. work correctly with _Excel_RangeRead($oWorkbook, Default, Default,2)

 

Thank you guys.

 

Saludos

 

 

Share this post


Link to post
Share on other sites

I am using "$WorkSheet.Cells(Row, Column).Value" for getting specific data from excel. Since, "Row" and "Column" are integer, it is easy to use inside a loop. 


My Contributions

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

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