;=============================================================================== ; Function Name: _WordCombineDocs($sNewDocPath, $aPathDocs, $fNewDocOpen = False) ; Description: verbindet Worddokumente in einem neuen Dokument (Dokumente bleiben erhalten) ; Parameter(s): $sNewDocPath - kpl. Pfad des neuen Dokuments ; $aPathDocs - Array mit den Pfaden der zu verbindenden Dokumente ; $fNewDocOpen - das neue Dokument öffnen ; $fVisible - wenn $fNewDocOpen=True das neue Dokument anzeigen od. nicht ; Return Value(s): Erfolg - WordObjekt (Word vorher nicht aktiv und $fNewDocOpen=False), sonst ; 1 ; Teilerfolg WordObjekt od. 1 und @error 2: eine/mehrere Dateien nicht gefunden ; @extended = Anzahl fehlender Dateien ; Fehler - 0 @error= 1 (kein Array übergeben) ; 3 keine Datei gefunden ; Author(s): BugFix (bugfix@autoit.de) ;=============================================================================== Func _WordCombineDocs($sNewDocPath, $aPathDocs, $fNewDocOpen = False, $fVisible = False) If Not IsArray($aPathDocs) Then Return SetError(1,0,0) Local $err = 0, $iErr = 0, $oWord, $sFileName, $fWordExists = False If ProcessExists('WINWORD.EXE') Then $oWord = ObjGet('', "Word.Application") $fWordExists = True Else $oWord = ObjCreate("Word.Application") $oWord.Visible = False EndIf $oWord.Documents.Add("") For $i = 0 To UBound($aPathDocs) -1 If Not FileExists($aPathDocs[$i]) Then $iErr += 1 ContinueLoop EndIf With $oWord.Selection .EndKey(6) .InsertBreak(7) .InsertFile($aPathDocs[$i]) EndWith Next If $iErr Then $err = 2 If $iErr = UBound($aPathDocs) Then If Not $fWordExists Then $oWord.Application.Quit(0) Return SetError(3,0,0) EndIf EndIf $oWord.ActiveDocument.SaveAs($sNewDocPath) If $fNewDocOpen Then $oWord.Visible = $fVisible $sFileName = StringRight($sNewDocPath, StringLen($sNewDocPath)-StringInStr($sNewDocPath, '\', 1, -1)) WinActivate($sFileName) Return SetError($err,$iErr,$oWord) Else If Not $fWordExists Then $oWord.Application.Quit(-1) Return SetError($err,$iErr,1) EndIf EndIf EndFunc ;==>_WordCombineDocs