hero88

_Excel_RangeFind exits with an error

13 posts in this topic

Hi

I have an issue with _ExcelRangeFind, i have a it working on another PC but on my pc i just gives me this error

"d:\AutoIt3\Include\Excel.au3" (656) : ==> The requested action with this object has failed.:
$aResult[$iIndex][1] = $oMatch.Name.Name
$aResult[$iIndex][1] = $oMatch^ ERROR

I have trimmed the script to the absolute minimum.

What iy should do, I give it a number, It opens an excel file, and then it reads through coloumn A and then returns an array when it finds the number in Excel. The number is in coloumn A of the Excel sheet.

The versions of autoit are the same on both machines.

The Excel sheet opens correctly, but it crashes on the rangefind command. I have also tried this $NavisionIDFound = _Excel_RangeFind($Movielistsheet,$NavisionID,"A1:A10000",Default,$xlWhole,True), with the same result.

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <File.au3>
#include <MsgBoxConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <GuiButton.au3>
#include <GuiComboBox.au3>
#include <Excel.au3>
;Includes from source dir
#include <_RecFileListToArray.au3>
#include <_XMLDomWrapper.au3>

$MovielistExcel = "h:\Movie list.xlsm"

LoadDataFromMovieListSheet()

Func LoadDataFromMovieListSheet()
ConsoleWrite("Load Data From MovieList Sheet" & @LF)
$NavisionID = 106266
; Create application object
$ExcelAppHandle = _Excel_Open(Default,Default,Default,Default,True)
If @error Then Exit MsgBox(16, "Excel UDF: _Excel_BookOpen Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
$Movielistsheet = _Excel_BookOpen($ExcelAppHandle, $MovielistExcel, True, Default)
;~ Read the formulas of a cell range (all used cells in column A)
$NavisionIDFound = _Excel_RangeFind($Movielistsheet,$NavisionID,$Movielistsheet.ActiveSheet.Usedrange.Columns("A:A"),Default,$xlWhole,True)

 

Share this post


Link to post
Share on other sites



Which version of AutoIt do you run?


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 was running 3.3.12.0, and then I upgraded to 3.3.14.2 to see it that fixed the problem.

Share this post


Link to post
Share on other sites

Seems to be a bug in AutoIt. If you do not need the name of the cell you could simply remove this line.


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

Okay, but how can I then search in excel? I have coloumn A where there is a number which I need to find.

Any suggestions?

Share this post


Link to post
Share on other sites

Use function _Excel_RangeFind as described in the help file after you have modified the following line in the UDF

$aResult[$iIndex][1] = $oMatch.Name.Name

to

; $aResult[$iIndex][1] = $oMatch.Name.Name

Now the name field in the returned array stays empty (not a big problem as users rarely use names for their cells).


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

It failed on Comments also, so i commented that out, so now it runs it just doesn't give me any result. But I am running a DK version of Excel, can this be the cause?

I will try to find an english version and see if it does anything.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

I commented both lines in AutoIt 3.3.15.0 and then it worked and returned a correct result.
What is the value of @error after running _Excel_RangeRead?

Edited by water

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

Hi Water

First of it was me being a fool. When I commented the 2 lines out it finds the required value.

I didn't have an _arraydisplay after, and that was why I thought it didn't work.

So thanks for the help in figuring this out.

Before I figured this out,I tried to run all 4_Excel_RangeFind examples from the help file. And 1,3 and 4 doesn't run. It errors out like this in all 3

"d:\AutoIt3\Include\Excel.au3" (670) : ==> The requested action with this object has failed.:
$oSheet = $oWorkbook.Sheets($iIndexSheets)
$oSheet = $oWorkbook^ ERROR

If I try with beta 3.3.15.0 it give me this error for 1 and 4 and the same error as in 3.3.14.2 for number 3

"d:\AutoIt3\Beta\Include\Excel.au3" (656) : ==> The requested action with this object has failed.:
$aResult[$iIndex][1] = $oMatch.Name.Name
$aResult[$iIndex][1] = $oMatch^ ERROR

I tried to readding the 2 lines in _Excel.au but it still gives the same error.

Hope you can use this information.

 

 

 

 

Share this post


Link to post
Share on other sites

#10 ·  Posted

Hi,

i have the same problem with my search:

$aSearch=_Excel_RangeFind($oWorkbook_2, $SpalteH, "B2:B10")

I can open the workbook, but i can't search for my variable in the workbook. With or without specifying range and column i get the following message:

"C:\Program Files (x86)\AutoIt3\Include\Excel.au3" (656) : ==> The requested action with this object has failed.:

$aResult[$iIndex][1] = $oMatch.Name.Name
$aResult[$iIndex][1] = $oMatch^ ERROR

Any advice?

Share this post


Link to post
Share on other sites

#11 ·  Posted

What causes the problem and how to solve it can be found here:

 


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

#12 ·  Posted

Hi Water,

i have updated the Excel.au3 and it worked.

Thank you so much.

Share this post


Link to post
Share on other sites

#13 ·  Posted

:)


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

  • Similar Content

    • LoneWolf_2106
      By LoneWolf_2106
      Hi,
      i have an error:
      ==> The requested action with this object has failed.: $iRowCount = .Range(.Cells(1, 1), .Cells($oRangeLast.Row, $oRangeLast.Column)).Rows.Count $iRowCount = .Range(^ ERROR  
      My code is:
      $oRangeLast = .UsedRange.SpecialCells($xlCellTypeLastCell) Sleep(1000) $iRowCount = .Range(.Cells(1, 1), .Cells($oRangeLast.Row, $oRangeLast.Column)).Rows.Count Sleep(1000) _Excel_RangeWrite($oWorkbook_1, $oWorkbook_1.ActiveSheet,$aFileList[$i][2] , "AB3:AB"&$iRowCount) I have added some sleep because the application was crashing more often before, so i thought to slow down the code execution.
      But i didn't solve the issue.
      Has anyone an idea of what the problem might be?
      Thanks in advance.
    • water
      By water
      Extensive library to control and manipulate Microsoft Excel charts.
      Written by GreenCan and water.
      Theads: General Help & Support - Example Scripts
      BTW: If you like this UDF please click the "I like this" button. This tells me where to next put my development effort

      KNOWN BUGS (last changed: 2017-07-21)
      None. The COM error handling related bugs have been fixed.
       
    • LoneWolf_2106
      By LoneWolf_2106
      Hi,
      i have a problem with the deletion of an empty row in Excel.
      My code:
       
      If $vRow_2 = "" Then _Excel_RangeDelete($oWorkbook_1.ActiveSheet,"2", $xlShiftUp,1) EndIf I want to delete the second row. $vRow_2 is an empty cell, "A2".
      After running the code, the second row is not deleted.
      I have tried also:
       
      If $vRow_2 = Null Then _Excel_RangeDelete($oWorkbook_1.ActiveSheet,"2", $xlShiftUp,1) EndIf But it doesn't work.
      Any suggestion?
      Thanks in advance.
    • VeryGut
      By VeryGut
      I'm trying to insert the following formula in cell A2 using my script:
      =if(A1=""; "YES"; "NO")
      To my understanding, the line of code should be similar to this:
      _Excel_RangeWrite($MasterFile, Default, "=if(A1=""; "YES"; "NO")", "A2")
      However, it does not work, probably due to the multiple quotation marks that confuse the script :C
      How do I avoid this problem?
    • LoneWolf_2106
      By LoneWolf_2106
      Hi everybody,
      i have a question about Excel, i have to create several charts one below the other dynamically.
      I have thought to use:
       
      $oRangeLast = .UsedRange.SpecialCells($xlCellTypeLastCell) $iRowCount = .Range(.Cells(1, 1), .Cells($oRangeLast.Row, $oRangeLast.Column)).Rows.Count  
      And then to use it in this way:
      $Graph_position = "=Test1!A"&$iRowCount+2&":K"&$iRowCount+24 But it doesn't work with charts.
      Does anyone have a suggestion?