Jump to content

Including Excel in my script


Recommended Posts

Hello All,

I have a very simple script that isn't working correctly and I was hoping that this forum could take a look at my script and tell me what I did wrong. Basically, I have a an Excel 2007 spreadsheet that has 100+ acct numbers in the first column. My script activates the excel doc, moves down one row, copies that cell and pastes it into an ERP. Everything works fine within the ERP part of the script, but at the end it starts a new ERP invoice and it is suppose to activate the excel doc, move down a row, and copy that cell. It works the first time but after that it will either not activate the excel doc, not move down one, or move down one but not copy the new cell.

Opt("MouseCoordMode", 0)

While 1 = 1

$i = 0

Do

WinSetState("Microsoft Excel", "", @SW_RESTORE)

WinActivate("Microsoft Excel")

WinWaitActive("Microsoft Excel")

Send("{down}")

WinWaitActive("Microsoft Excel")

Send("^c") ;;; #cs copy cell from excel ;;; #ce

WinSetState("Invoice Entry", "", @SW_RESTORE)

WinActivate("Invoice Entry")

WinWaitActive("Invoice Entry")

MouseClick("left", 150, 100, 2 , 25 ) ;;;#cs selects invoice box ;;; #ce

Send("{TAB}")

Send("^v") ;;; #cs pastes # in customer box ;;; #ce

Send("{TAB}")

Send("!c") ;;; #cs calls invoice search/accounts receivable invoice screen ;;; #ce

WinWaitActive("Accounts Receivable Invoices")

MouseClick("left",60,120, 2) ;;; #cs selects first line in invoice ;;; #ce

WinClose("Accounts Receivable Invoices")

WinWaitActive("Invoice Entry")

WinWaitActive("Invoice Entry")

MouseClick("left", 285, 68, 1) ;;; #cs selects the "apply credit memo" button ;;; #ce

WinWaitActive("Apply Credit Memo", "", 5)

MouseClick("left", 387, 69, 1) ;;; #cs selects the "Amount Applied" cell in the first line of data ;;; #ce

MouseClick("left", 52, 409, 1) ;;; #cs selects the save button ;;; #ce

WinWaitActive("Invoice Entry")

MouseClick("left", 285, 68, 1) ;;; #cs selects the "apply credit memo" button ;;; #ce

WinWaitActive("Apply Credit Memo")

If MouseClick("left",387, 87, 1) = "" Then

Send("!C")

Else

MouseClick("left", 52, 409, 1) ;;; #cs selects the save button ;;; #ce

EndIf

WinWaitActive("Invoice Entry")

MouseClick("left", 285, 68, 1) ;;; #cs selects the "apply credit memo" button ;;; #ce

WinWaitActive("Apply Credit Memo")

If MouseClick("left",387, 105, 1) = "" Then

Send("!C")

Else

MouseClick("left", 52, 409, 1) ;;; #cs selects the save button ;;; #ce

EndIf

WinWaitActive("Invoice Entry")

MouseClick("left", 47, 68, 1)

$i = $i + 1

Until $i = 200

If $i = 200 then

Endif

Wend

I am very new to this program so please mind my ignorance. Any help would be greatly appreciated.

Thank You,

Ramona

Link to comment
Share on other sites

Don't do it the way you do it right now if you want a reliable and dummy proof solution ;)

AutoIt comes with an Excel UDF (User Defined Functions) which lets you easily and reliably automate Excel.

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

  • 1 year later...

Welcome to AutoIt and the forum!

Isn't your post a bit late? bouncyball89 left the forum 1 1/2 years ago.

Edited by water

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