Nach Auswahl des "combo" Firma sollten die restlichen Informationen gezogen werden

  • Hallo Zusammen
    Bitte, möchte mein script erweitern und zwar nach auswahl der "Firma" sollte nach drücken des Buttons "Offerte" die restlichen Informationen wie z.B. Name, Vorname, Strasse, und Ort aus der entsprechender Zeile gezogen werden.
    Währe wirklich sehr dankbar um hilfe.
    MC

    Spoiler anzeigen
    [autoit]

    #include<Array.au3>
    ;#include<ExcelCOM_UDF.au3>
    #include<Excel.au3>
    Opt('MustDeclareVars', 1)

    [/autoit] [autoit][/autoit] [autoit]

    ArrayMuster()
    Func ArrayMuster()

    [/autoit] [autoit][/autoit] [autoit]

    Global $aIni, $nMsg, $Exit, $ab, $Offerte, $mwRechnung, $owRechnung, $Exit, $aFirma, $combobox
    Global $xls, $xlsdir, $app, $zelle, $zeile, $open
    Local $aFileName, $aArray1, $oExcel
    $aFileName = ("C:\temp\Script\Firmenmusteradressen.xls")
    $oExcel = _ExcelBookOpen($aFileName) ;Open book, make it not visible
    $oExcel.Visible = 0
    $aArray1 = _ExcelReadArray($oExcel, 2, 1, 11, 1) ;Direction is Vertical
    _ArrayDisplay($aArray1, "Arrray Range FIRMA")
    $oExcel = _ExcelBookClose($aFileName)
    $aFirma = _ArrayToString($aArray1)

    [/autoit] [autoit][/autoit] [autoit]

    GUICreate("GUI", 300, 260)
    GUICtrlCreateLabel("Firma ", 10, 10)
    $combobox = GUICtrlCreateCombo("", 10, 30, 190)
    GUICtrlSetData($combobox, $aFirma)

    [/autoit] [autoit][/autoit] [autoit]

    $ab = GUICtrlCreateButton("Abestätigung",70, 130)
    $Offerte = GUICtrlCreateButton("Offerte",10, 130)
    $mwRechnung = GUICtrlCreateButton("Rechnung mit WIR",150, 130)
    $owRechnung = GUICtrlCreateButton("Rechnung ohne WIR",150, 160)
    $Exit = GUICtrlCreateButton("Exit",60, 200)

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    If Not FileExists($aFileName) Then ; Neu zur Überprüfung hinzu
    MsgBox(0, "Hinweis:", "XLS-Datei existiert nicht.")
    Exit
    EndIf
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $Exit
    ;MsgBox(1,"Auswahl", GUICtrlRead($MengenCombo[0])&GUICtrlRead($MengenCombo[1])& _
    ; GUICtrlRead($MengenCombo[2])&GUICtrlRead($MengenCombo[3]))
    Exit
    Case $mwRechnung
    Run("C:\Program Files\Microsoft Office\Office12\excel")
    Exit
    Case $owRechnung
    Run("C:\Program Files\Microsoft Office\Office12\excel")
    Exit
    Case $Offerte
    ;Msgbox(1,"", $combobox)
    ;$xls = ShellExecute("C:\temp\Script\OffertenvorlageNEU.xls")
    $xlsdir = "C:\temp\Script\OffertenvorlageNEU.xls"
    ;Excel öffnen
    $app = ObjCreate("Excel.application")
    $app.Visible = true
    $open = $app.Workbooks.Open ($xlsdir)
    ;in Excel schreiben
    $app.Cells(10,4).Value = ""&GUICtrlRead($combobox)&""

    [/autoit] [autoit][/autoit] [autoit]

    $zelle=6
    $zeile=1
    $app.Cells($zeile,$zelle).Value = ""
    ;$open = $app.Workbooks.Close($xlsdir)
    Exit
    EndSwitch
    WEnd
    EndFunc

    [/autoit]
  • Spoiler anzeigen
    [autoit]

    #include<Array.au3>
    ;#include<ExcelCOM_UDF.au3>
    #include<Excel.au3>
    #include <ComboConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    $aFileName = ("C:\temp\Script\Firmenmusteradressen.xls")
    GUICreate("GUI", 300, 260)
    GUICtrlCreateLabel("Firma ", 10, 10)
    $combobox = GUICtrlCreateCombo("", 10, 30, 190, Default, $CBS_DROPDOWNLIST)

    [/autoit] [autoit][/autoit] [autoit]

    $oExcel = _ExcelBookOpen($aFileName, 0) ;Open book, make it not visible
    Local $ComboText = ''
    $aArray1 = _ExcelReadSheetToArray($oExcel, 2)
    If IsArray($aArray1) Then
    For $i = 1 To UBound($aArray1) - 1
    $ComboText &= $aArray1[$i][1] & "|"
    Next
    $oExcel = _ExcelBookClose($aFileName)
    GUICtrlSetData($combobox, StringTrimRight($ComboText, 1), $aArray1[1][1])
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    $ab = GUICtrlCreateButton("Abestätigung", 70, 130)
    $Offerte = GUICtrlCreateButton("Offerte", 10, 130)
    $mwRechnung = GUICtrlCreateButton("Rechnung mit WIR", 150, 130)
    $owRechnung = GUICtrlCreateButton("Rechnung ohne WIR", 150, 160)
    $Exit = GUICtrlCreateButton("Exit", 60, 200)

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    If Not FileExists($aFileName) Then ; Neu zur Überprüfung hinzu
    MsgBox(0, "Hinweis:", "XLS-Datei existiert nicht.")
    Exit
    EndIf
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $Exit
    ;MsgBox(1,"Auswahl", GUICtrlRead($MengenCombo[0])&GUICtrlRead($MengenCombo[1])& _
    ; GUICtrlRead($MengenCombo[2])&GUICtrlRead($MengenCombo[3]))
    Exit
    Case $mwRechnung
    Run("C:\Program Files\Microsoft Office\Office12\excel")
    Exit
    Case $owRechnung
    Run("C:\Program Files\Microsoft Office\Office12\excel")
    Exit
    Case $Offerte
    If IsArray($aArray1) Then
    For $i = 1 To UBound($aArray1) - 1
    If $aArray1[$i][1] = GUICtrlRead($combobox) Then
    ExitLoop
    EndIf
    Next
    MsgBox(0, "", $aArray1[$i][1] & @LF & $aArray1[$i][2] & @LF & $aArray1[$i][3] & @LF & $aArray1[$i][4] & @LF & $aArray1[$i][5] & @LF & $aArray1[$i][6] & @LF & $aArray1[$i][7])
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    ;$xls = ShellExecute("C:\temp\Script\OffertenvorlageNEU.xls")
    $xlsdir = "C:\temp\Script\OffertenvorlageNEU.xls"
    ;Excel öffnen
    $app = ObjCreate("Excel.application")
    $app.Visible = True
    $open = $app.Workbooks.Open($xlsdir)
    ;in Excel schreiben
    $app.Cells(10, 4).Value = "" & GUICtrlRead($combobox) & ""

    [/autoit] [autoit][/autoit] [autoit]

    $zelle = 6
    $zeile = 1
    $app.Cells($zeile, $zelle).Value = ""
    ;$open = $app.Workbooks.Close($xlsdir)
    Exit
    EndSwitch
    WEnd

    [/autoit]