Jump to content

Request object failed for Excel

Recommended Posts

Hello guys,

I really cannot find a way to solve this error.so please help

I  have an excel file (example Test.xlsx) say with  34 sheets (sheets can vary from excel file to file)

i need to traverse to all the 34 sheets and check for a word .

After finding the word i need to apply certain condition  and then write the information in another excel (Config.xlsm)

when i do this process it throws Request object failed  Error . However if the sheets are less lets say 10 then i will not have any problem.


Since  their is so many Read , Find , and Write to the excel  i thought that could be the problem .

so i only used find and _ExcelRead and after Finding the value  i am writing it the Notepad. from NotePad i process the data.

But unfortunately  i still get that message rarely . Please help me 



For $j=0 to UBound($VerMSN)-1

   For $i=3 to UBound($sheet_names)-1
      SplashTextOn("Progress","Reading  through validity sheets...",500,100,Default,Default,33)
      if(StringInStr($sheet_names[$i][0],"Validity")<>0) Then

         $valSheet = $eWorkbook.Sheets($sheet_names[$i][0])
         $fRes = FindRange($VerMSN[$j][1],$valSheet.Range("D:D"))

         If UBound($fRes)>0 Then
            If  UBound($fRes)>1 Then
               For $f=0 to UBound($fRes)-1

Func WriteToFile($verAddress,$sheetName,$eWorkbook,$realRank,$Msn,$Fileopen,$Fileopen1,$Revision)
      $address= StringMid($verAddress,StringInStr($verAddress,"$",0,2)+1,3)
      $FAL=_Excel_RangeRead($eWorkbook,$sheetName,"B" & $address)
      $RangeFrom=_Excel_RangeRead($eWorkbook,$sheetName,"E" & $address)
      $RangeTo=_Excel_RangeRead($eWorkbook,$sheetName,"F" & $address)

   For $k=1 to UBound($realRank)-1
      If $realRank[$k]<>"" Then

         $Root =Rootvalue($Circuit,$sheetName)
         If $realRank[$k]>=$RangeFrom And $realRank[$k]<=$RangeTo Then
            FileWriteLine($Fileopen,$Revision &"            " & $Msn[$k] &"             "& $FAL &"            "& $Circuit& "            "  & $Root)
            FileWriteLine($Fileopen1,$Revision &"            " & $Msn[$k] &"             "& "None" &"            "& $Circuit& "            "  & $Root)

;Find the version
Func FindRange($Search,$vRange)
   Local $aResult[100],$iIndex = 0
   Local $oMatch = $vRange.Find($Search)
   If IsObj($oMatch) Then
      $sFirst = $oMatch.Address
      While 1
          $aResult[$iIndex] = $oMatch.Address
          $iIndex = $iIndex + 1
          If Mod($iIndex, 100) = 0 Then ReDim $aResult[UBound($aResult, 1) + 100]
          $oMatch = $vRange.Findnext($oMatch)
          If Not IsObj($oMatch) Or $sFirst = $oMatch.Address Then ExitLoop
   ReDim $aResult[$iIndex]
   Return $aResult

Func Rootvalue($Circuit,$sheet_names)
   Return $Root




Link to post
Share on other sites

Unfortunately, your code is partial and unrunable.  So it is impossible for us to test it.  I would suggest that you make a runable snippet of your code and provide the .xlsx file so we can fully test it.

In any case, you may need to intercept COM errors.  See help file under Obj/COM reference to get an example how to do it...

Link to post
Share on other sites
20 minutes ago, Juvigy said:

is a valid sheet name

... or index.

My UDFs and Tutorials:


Active Directory (NEW 2021-06-05 - Version - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version - Download - General Help & Support - Example Scripts
OutlookEX (NEW 2021-06-14 - Version - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version - Download
Outlook Tools (2019-07-22 - Version - Download - General Help & Support - Wiki
PowerPoint (NEW 2021-08-31 - Version - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2019-12-03 - Version - Download - General Help & Support - Wiki

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

ADO - Wiki
WebDriver - Wiki


Link to post
Share on other sites
37 minutes ago, Juvigy said:

 is a valid sheet name?

I supposed he is using _Excel_SheetList ?  Like I said, the script is too incomplete, we can only guess...

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...