litlmike

Variable must be of type "Object"

2 posts in this topic

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

 

 

 

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

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

    • JamesDover
      By JamesDover
      I am using the version of Excel.au3 that came with auto-it but it says undefined function when I try to run it. Here is the code.
      Thanks 
      Local $oExcel = _ExcelBookNew() ===================SHOWS undefinded function _ExcelWriteSheetFromArray($oExcel, $Model1, 1, 1, 0, 0) ===================SHOWS undefinded function