Jump to content

script opens the excel file again and again


 Share

Recommended Posts

Hello my friends,

I wrote a simple script that writes a column in excel to a web page. But the script opens the excel again and again for no reason :(

This is my script:

Local $oExcel = _ExcelBookOpen(//here I put the excel path)

Global $aArray = _ExcelReadSheetToArray($oExcel)

MouseClick("left",$start_pos_web_x,$start_pos_web_y,1,0)

For $i = 1 To 5

Send($aArray[$i][1])

Send("{TAB}")

Send("{TAB}")

Next

I want to paste the array items in the web page (first I go to the first form-which is done with the mouseClick function, and then I skip the forms with 2 tabs).

I don't understand why it opens the excel each time (its not even in a loop).

Link to comment
Share on other sites

Is this the whole script?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

this is most of the script.

This is the full one:

#include <Array.au3>

#include <Excel.au3>

HotKeySet("t","doWork")

HotKeySet("{ESC}", "Terminate")

While 1

Sleep(100)

WEnd

Func doWork()

Const $sFilePath1 = "//my excel file"

Global $oExcel = _ExcelBookOpen($sFilePath1)

Const $start_pos_web_x=890,$start_pos_web_y=287

If @error = 1 Then

MsgBox(0, "Error!", "Unable to Create the Excel Object")

Exit

ElseIf @error = 2 Then

MsgBox(0, "Error!", "File does not exist - Shame on you!")

Exit

EndIf

Global $aArray = _ExcelReadSheetToArray($oExcel)

MouseClick("left",$start_pos_web_x,$start_pos_web_y,1,0)

For $i = 1 To 5

Send($aArray[$i][1])

Send("{TAB}")

Send("{TAB}")

Next

EndFunc

Func Terminate()

Exit

EndFunc

Link to comment
Share on other sites

Hi,

The HotKeySet function calls your function until you release the key.

Add this in your function to avoid the overlapping :

Func doWork()
   Local Static $blFuncFinished = True
   If Not $blFuncFinished Then Return ;void
   $blFuncFinished = False

   ;doWork here

    $blFuncFinished = True
EndFunc

Br, FireFox.

Link to comment
Share on other sites

A few suggestions on how to improve your script:

  • Always check for errors immediately after a function call e.g. after _ExcelBookOpen
  • Don't use screen coordinates to click on buttons or enter data. They depend ons creen resolution and position of the window you try to automate
  • Use the IE UDF to enter data into web form fields (if you use the Internet Explorer)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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