Jump to content

Need some directions with Excel


Go to solution Solved by Andreik,

Recommended Posts

Hello everyone!

I need some direction how schould i approach my problem. I have a spreadsheet lets say A and B with around 60 positions now depends whats number is in A and B the script schould do some input for example press arrow two times down then press enter and move to next position. Any ideas ? i loaded the spreadsheet into an array and then i got lost :)

Link to comment
Share on other sites

Link to comment
Share on other sites

#include <Array.au3>
#include <Excel.au3>

Global $iTotalTime = 0

Test()

Func Test()
    Local $oExcel = _Excel_Open()
    Local $oBook = _Excel_BookAttach("Test.xlsx", "FileName", $oExcel)
    Local $sSheet = "Sheet1"
    If @error Then Return MsgBox($MB_ICONERROR, "Excel Failed", "Failed to attach to Excel")

    Local $iNum
    Local $aData = _Excel_RangeRead($oBook, $sSheet, "A1:B164", 1, True)
    _ArrayDisplay($aData)
 EndFunc

Like i said i just loaded the excel spreadsheet into array thats it. So In the spreadsheet a1 is 10 b1 is 104. so the script should switch focus to other program (i know how to do that) then press enter press 1 then 0 enter then 104 enter then move to A2:B2 and do the same till the end of the spreadsheet. i assume a loop is not a good idea if there is a lot of entrys. Im also a begginer in autoit but want to learn it. Big Thanks for help.

Test.xlsx

Link to comment
Share on other sites

  • Solution

Something like this?

#include <Excel.au3>

Test()

Func Test()
    Local $oExcel = _Excel_Open(False)
    Local $oBook = _Excel_BookOpen($oExcel, @ScriptDir & '\Test.xlsx', True, False)
    Local $aData = _Excel_RangeRead($oBook, Default, 'A1:B164', 1, True)
    _Excel_Close($oExcel)
    Local $aSplit
    For $Index = 0 To UBound($aData) - 1
        If Not $aData[$Index][0] Then ContinueLoop
        ; Focus here your desired window
        Send('{ENTER}' & $aData[$Index][0] & $aData[$Index][1] & '{ENTER}')
        ; As an alternative you migth want to use ControlSend()
    Next
EndFunc

 

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...