Jump to content

From Gui To Excel


Recommended Posts

ok so this is my first time here and well NICE i see im a little far behind but meh i only just started today so.

my problem is that i type any text into the gui input boxes and click input to send them to a spreadsheet in excel but

it doesn't input my text it inputs 8 9 10 11 12 dunno why its those number or how anyone share any light il hug ya XD.

heres my script atm:

;===============================================================================
;
; Description:      Show all icons in the given file
;
;===============================================================================

#include <ExcelCOM_UDF.au3>  ; Include the collection
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>

Opt('MustDeclareVars', 1)

_Main()

Func _Main()
    
    Global $input1, $input2, $input3, $input4, $input5, $input6, $count
    Global $input1a, $input2a, $input3a, $input4a, $input5a, $input6a
    Global $msg
    Global $xx, $yy, $down, $nextrow, $lastused, $avdata, $n, $file, $oExcel, $right, $hinput, $hreset, $hexit, $BS_FLAT, $msg, $avdata
    GUICreate("Fuel Sheet Helper ..:: Created By Kris ::..", 469, 205, (@DesktopWidth - 469) / 2, (@DesktopHeight - 639) / 2, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
    
    GUICtrlCreateLabel("Fleet No.", 10, 20, 150, 20)
    GUICtrlSetTip(-1, "Enter The Feelt No.")
    GUICtrlCreateLabel("Rego No.", 10, 50, 150, 20)
    GUICtrlSetTip(-1, "Enter The Rego No.")
    GUICtrlCreateLabel("Fuel", 10, 80, 150, 20)
    GUICtrlSetTip(-1, "Enter The Fuel")
    GUICtrlCreateLabel("Total", 10, 110, 150, 20)
    GUICtrlSetTip(-1, "Enter The Total Fuel Cost")
    GUICtrlCreateLabel("Rebate", 10, 140, 150, 20)
    GUICtrlSetTip(-1, "How Much Is The Rebate")

    $Input1 = GUICtrlCreateInput("" , 180, 10, 280, 20)
    $Input2 = GUICtrlCreateInput("" , 180, 40, 280, 20)
    $Input3 = GUICtrlCreateInput("" , 180, 70, 280, 20)
    $Input4 = GUICtrlCreateInput("" , 180, 100, 280, 20)
    $Input5 = GUICtrlCreateInput("" , 180, 130, 280, 20)
    
    $hinput = GUICtrlCreateButton("Input", 230, 160, 80, 40, $BS_FLAT)
    $hreset = GUICtrlCreateButton("Reset", 330, 160, 80, 40, $BS_FLAT)
    
    $right = 1
    $count = 0
    
    ; Open new book,
    $file = @ScriptDir & "\excel2.xlsx"
    $oExcel = _ExcelBookOpen($file, 1) ; open excel in the background
    
    ;find the last used cell in this coloum
    global $avdata = _ExcelReadArray($oExcel, 1, 1, 1000, 1, 1)
    global $lastused = 0, $nextrow = 0
    for $n = ubound($avdata) -1 to 1 step -1
        if stringstripWS($avdata[$n], 8) <> "" Then
            ExitLoop
        EndIf
    Next
    
    GUISetState()
    
    Send("!{TAB 1}")
    
    ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $hreset
                GUICtrlSetData($input1, "")
                GUICtrlSetData($input2, "")
                GUICtrlSetData($input3, "")
                GUICtrlSetData($input4, "")
                GUICtrlSetData($input5, "")
                
            Case $msg = $hinput
                
                $Input1a = $Input1
                $Input2a = $Input2
                $Input3a = $Input3
                $Input4a = $Input4
                $Input5a = $Input5
                    
                $down = $n + 1 + $count
                
                $right = 1
                
                ; Input Box 1
                $yy= $down
                $xx = $right
                _ExcelWriteCell($oExcel, $Input1a, $yy, $xx)
                $right = $right + 1

                ; Input Box 2
                $yy= $down
                $xx = $right
                _ExcelWriteCell($oExcel, $Input2a, $yy, $xx)
                $right = $right + 1

                ; Input Box 3
                $yy= $down
                $xx = $right
                _ExcelWriteCell($oExcel, $Input3a, $yy, $xx)
                $right = $right + 1

                ; Input Box 4
                $yy= $down
                $xx = $right
                _ExcelWriteCell($oExcel, $Input4a,, $yy, $xx)
                $right = $right + 1

                ; Input Box 5
                $yy= $down
                $xx = $right
                _ExcelWriteCell($oExcel, $Input5a,, $yy, $xx)
                $right = $right + 1
                $down = $down + 1
                $count = $count + 1
                
                _ExcelBookSaveAs($oExcel, @ScriptDir & "\excel2.xlsx", "xlsx", 0, 1)

                
            EndSelect
            If $msg = $GUI_EVENT_CLOSE Then ExitLoop
            WEnd
            _ExcelBookSaveAs($oExcel, @ScriptDir & "\excel2.xlsx", "xlsx", 0, 1)
EndFunc   ;==>_GUIUpdate
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...