I need some help here,
I'm having trouble with my Word object:
Arrays are filled, word document opens fine, $oWordApp is object , first loop "For $j = 0" works (first array element is processed in Word) but then I get the following error :
The requested action with this object has failed.:
$oWordApp.Selection.TypeText($aStreng[$j])
$oWordApp.Selection.TypeText($aStreng[$j])^ ERROR
i'm a little bit lost here.. please help
oh, and the code :
If FileExists($sFilePath1) Then ;---> check of bestand bestaat
If WinExists($Project & " Strenggegevens.xls") Then
MsgBox(262144, "", "Excel bestand is open")
WinClose($Project & " Strenggegevens.xls")
WinWaitClose($Project & " Strenggegevens.xls")
$oExcel = _ExcelBookOpen($sFilePath1)
Else ;---> open excel bestand
$oExcel = _ExcelBookOpen($sFilePath1)
EndIf
Else
MsgBox(262144, "error", "Strenggegevens bestaan niet, aan het werk luie hond! ;)", 2)
EndIf
If IsObj($oExcel) Then
$nStrengen = _ExcelReadCell($oExcel, 1, 1)
$oWordApp = _WordCreate($templateWord)
$oWordApp.activedocument.SaveAs($sDirProjecten & $Project & "\" & $Project & " StrengRapport.doc")
For $i = 4 To $nStrengen
$aStreng = _ExcelReadArray($oExcel, $i, 1, 33)
;~ _ArrayDisplay($aStreng)
For $j = 0 To UBound($aStreng) - 1
If IsObj($oWordApp) Then ;<--- control line!!
$oWordApp.Selection.TypeText($aStreng[$j])
$oWordApp.Selection.TypeParagraph
Sleep(100)
ConsoleWrite($aStreng[$j] & @CRLF)
EndIf
Next
$oWordApp.Selection.TypeParagraph
Next
$oWordApp.Selection.TypeParagraph
$oWordApp.Selection.TypeText("----------------")
$oWordApp.Selection.TypeParagraph
$oWordApp.Selection.TypeText("totaal aantal strengen = " & $nStrengen)
Endif