Jump to content

Variable must be of type "Object"


Recommended Posts

Hello, I am receiving the following error:

Quote

"C:\Program Files (x86)\AutoIt3\Include\Excel.au3" (227) : ==> Variable must be of type "Object".:
$oExcel.Windows($oWorkbook.Name).Visible = $bVisible
$oExcel.Windows($oWorkbook.Name)^ ERROR
->09:42:00 AutoIt3.exe ended.rc:1
+>09:42:00 AutoIt3Wrapper Finished.
>Exit code: 1    Time: 6.501

What is strange (to me), is that this error only occurs during a loop.  If I manually iterate through each count, it works fine, but as soon as I put it back in the loop, it shows this error.  I would appreciate any feedback you can give.  I will post code below.

Local $sFilePathForILPs = @ScriptDir & "\ILPs"
Local $aArrayOfILP_Files = _GetListOfILPsInDirectoryToBatch($sFilePathForILPs)

For $iCC = 1 To UBound($aArrayOfILP_Files) - 1

Local $oILPWorkbook = _Excel_BookOpen($oExcel, $sFilePathForILPs & "\" & $aArrayOfILP_Files[$iCC])
    If @error Then
        MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeWrite Example", "Error creating the new workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
        _Excel_Close($oExcel)
        Exit
    EndIf
    $sStudentLastName = _GetStudentLastNameFromILP($oILPWorkbook, $sExcelTabForCurrentMSPR)
    
    _FillInTheNumberofLessonsCompleted_History($oILPWorkbook, $oILPWorkbookClassProgress, $sExcelTabForCurrentMSPR, $sStudentLastName)

_Excel_BookClose($oILPWorkbook, True)

Next




Func _FillInTheNumberofLessonsCompleted_History($oILPWorkbook, $oILPWorkbookClassProgress, $sExcelTabForCurrentMSPR, $sStudentLastName)
    ;Read Student Name from 'Start Here' Tab
    ;Match Name into ClassProgress_Compiled File
    ;Search for name, subject
    ;Then use that Range to get the Number of Lessons Completed
    
    ;Put Excel File Into an Array
    Local $aArrayOfClassProgress = _Excel_RangeRead($oILPWorkbookClassProgress)
    Local $iIndexOfStudentLastName = _ArraySearch($aArrayOfClassProgress, $sStudentLastName)
    Local $iTotalNumberofCompletedLessons
    Local $sRangeForNumberofLessonsCompleted_History = "F31"

    ;Must loop through since there are multiple entries for every name
    Do
        $iIndexOfStudentLastName = _ArraySearch($aArrayOfClassProgress, $sStudentLastName, $iIndexOfStudentLastName + 1)
        $sSubject = $aArrayOfClassProgress[$iIndexOfStudentLastName][4]
        $sCourseName = $aArrayOfClassProgress[$iIndexOfStudentLastName][5]
        If $sSubject = "History" Then
            If $sCourseName = "History 3" Then
                $iTotalNumberofCompletedLessons = $aArrayOfClassProgress[$iIndexOfStudentLastName][6]
            EndIf
        EndIf
    Until $iTotalNumberofCompletedLessons <> 0

    _Excel_RangeWrite($oILPWorkbook, $sExcelTabForCurrentMSPR, $iTotalNumberofCompletedLessons - 54, $sRangeForNumberofLessonsCompleted_History)
EndFunc   ;==>_FillInTheNumberofLessonsCompleted_History

Func _GetListOfILPsInDirectoryToBatch($sFilePathForILPs)
    Local $aArrayOfILP_Files
    $aArrayOfILP_Files = _FileListToArray($sFilePathForILPs)
    Return $aArrayOfILP_Files
EndFunc   ;==>_GetListOfILPsInDirectoryToBatch

 

 

 

Link to comment
Share on other sites

Which version of AutoIt do you run?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

×
×
  • Create New...