Hilfe bei Excel.au3

  • Hallo Zusammen,

    ich brauche eure Hilfe. Ich will mit einer Gui Namen und Vornamen in eine Excel speichern.

    Wie bekomme ich es hin, dass das Skript automtaisch erkennt, das in der Excel Zeile schon etwas drin steht und automatisch den Wert in die nächste schreibt.?

    Spoiler anzeigen


    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <excel.au3>

    global $name,$vorname

    form()

    func form()
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 526, 97, 192, 114)
    $label2 = GUICtrlCreateLabel("Vorname", 232, 0, 69, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $label1 = GUICtrlCreateLabel("Name", 0, 0, 46, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $name = GUICtrlCreateInput("", 49, 0, 167, 21)
    $vorname = GUICtrlCreateInput("", 304, 0, 167, 21)
    $Button1 = GUICtrlCreateButton("In Excel speichen", 144, 48, 227, 25, $WS_GROUP)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    case $Button1
    Excel()
    EndSwitch
    WEnd
    EndFunc

    func Excel()
    $Excel = _ExcelBookOpen("C:\namen.xls", 0)
    _ExcelWriteCell($Excel, GUICtrlRead($vorname,1), 2, 2) ;Write to the Cell
    _ExcelWriteCell($Excel, GUICtrlRead($name,1), 2, 3) ;Write to the Cell
    _ExcelBookClose($Excel, 1, 0)
    EndFunc

  • Hallo billemg,

    so sollte es funktionieren:

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <excel.au3>

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

    Global $name, $vorname

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

    form()

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

    Func form()
    #region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 526, 97, 192, 114)
    $label2 = GUICtrlCreateLabel("Vorname", 232, 0, 69, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $label1 = GUICtrlCreateLabel("Name", 0, 0, 46, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $name = GUICtrlCreateInput("", 49, 0, 167, 21)
    $vorname = GUICtrlCreateInput("", 304, 0, 167, 21)
    $Button1 = GUICtrlCreateButton("In Excel speichen", 144, 48, 227, 25, $WS_GROUP)
    GUISetState(@SW_SHOW)
    #endregion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    Excel()
    EndSwitch
    WEnd
    EndFunc ;==>form

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

    Func Excel()
    $Excel = _ExcelBookOpen("C:\namen.xls", 0)
    $i = 1
    Do
    $i += 1
    $sOldV = _ExcelReadCell($Excel, $i, 2) ;Read from the Cell
    $sOldN = _ExcelReadCell($Excel, $i, 3) ;Read from the Cell
    Until $oldV = "" And $sOldN = ""
    _ExcelWriteCell($Excel, GUICtrlRead($vorname, 1), $i, 2) ;Write to the Cell
    _ExcelWriteCell($Excel, GUICtrlRead($name, 1), $i, 3) ;Write to the Cell
    _ExcelBookClose($Excel, 1, 0)
    EndFunc ;==>Excel

    [/autoit]

    ich habe aber kein Excel installiert, kann es daher nicht testen,

    mfg (Auto)Bert