water:
Ist damit dieses hier geklärt: Du verwendest _Excel_BookOpen UND _Excel_BookAttach ?
Test-Script schaut aktuell wie folgt aus:
Spoiler anzeigen
#include <Excel.au3>
#include <MsgBoxConstants.au3>
$first_in = "Alsterbogen"
[/autoit] [autoit][/autoit] [autoit]; Create application object and open an example workbook
Global $sFilePath = @ScriptDir & "\test.xlsx"
Local $oExcel = _Excel_Open(False, False, True, True, True)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookAttach Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookOpen($oExcel, $sFilePath)
If @error Then
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookAttach Example", "Error opening workbook '" & $sFilePath & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
_Excel_Close($oExcel)
Exit
EndIf
; *****************************************************************************
; Attach to the first Workbook where the file path matches
;DIREKT EINE ZELLE ANSPRECHEN
; *****************************************************************************
$oWorkbook = _Excel_BookAttach($sFilePath)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookAttach Example 1", "Error attaching to '" & $sFilePath & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookAttach Example 1", "Search by 'filepath':" & @CRLF & @CRLF & "Successfully attached to Workbook '" & $sFilePath & "'." & @CRLF & @CRLF & "Ausgelesener Wert aus A15: " & $oWorkbook.Activesheet.Range("A15").Value & @CR & "Aber diese Angabe ist nicht dynamisch. Also eine gewisse Zelle wird ausgelesen.")
; *****************************************************************************
; Display a list of all worksheets for a specific Workbook
; TABELLENBLATTNAME
; *****************************************************************************
Local $aWorkSheets = _Excel_SheetList($oWorkbook)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_SheetList Example 1", "Error listing Worksheets." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
_ArrayDisplay($aWorkSheets, "Excel UDF: _Excel_SheetList Example 1")
; *****************************************************************************
; Find all occurrences of value $first_in (partial match)
; SUCHT NACH $first_in
; *****************************************************************************
Local $aResult = _Excel_RangeFind($oWorkbook, $first_in)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeFind Example 1", "Error searching the range." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeFind Example 1", "Find all occurrences of value " & $first_in & " (partial match)." & @CRLF & "Data successfully searched.")
_ArrayDisplay($aResult, "Excel UDF: _Excel_RangeFind Example 1", "", 0, "|", "Sheet|Name|Cell|Value|Formula|Comment")
Local $text = StringReplace($aResult[0][2], "$A$", "$B$")
Local $numreplacements = @extended
Local $text2 = StringReplace($aResult[0][2], "$A$", "$C$")
Local $numreplacements2 = @extended
MsgBox(0, "Der neue String, der nun aus der Exycel-Tabelle ausgelesen werden soll: ", $text & @CR & $text2)
$sCellValue = _Excel_RangeRead($oWorkbook, Default, $text)
$sCellValue2 = _Excel_RangeRead($oWorkbook, Default, $text2)
MsgBox(0, "", "Die beiden Zellwerte sind: " & @CRLF & $sCellValue & @CRLF & "und" & @CRLF & $sCellValue2)
_Excel_BookClose($oWorkbook)
[/autoit] [autoit][/autoit] [autoit]_Excel_Close($oExcel, False)
[/autoit]