Jump to content

n00b help with automating Excel sheets


Recommended Posts

Hi everyone!

I'm new to autoit, and been fiddlin around with it for some days, trying to make a script that will load data from excell sheets into a form on a website.

So far so good, the basics have been covered, but the problems started when I had to switch between windows (IE & Excel). I tried the Controllistvieuw option etc, but Au3info doesnt give me a Controller ID for the sheet.

So I'm looking for a line of code that'll switcht between windows, or some other good way to select individual or grouped cells in Excel!

Thanks in advance!

Thomas

Link to comment
Share on other sites

There are UDFs (User defined functions) available for Excel and Internet Explorer. See Help File -> User Defined Functions -> Excel Management and IE Management.

That should get you started.

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

Well, I'm still baffled,

Before I just set keycombos to navigate & copy, but I really can't get the ExcelReadCell comand to work.

This is what I got so far on the Excel side of things, while I tried to get the data from cell C11 from the TestCleanSheet into my Clipboard:

Run(@comspec & ' /c "C:\Documents and Settings\Adminstrator\Desktop\Projects\Dat\TestCleanSheet.xls"','',@sw_hide)

Opt("WinTitleMatchMode", 3)

WinWaitActive( "Microsoft Excel - TestCleanSheet.xls")

#Include <Excel.au3>

$val = _ExcelReadCell($TestCleanSheet.xls, $C11)

Is the whole clipboard thing even nescesary, or is their another way to get the returned Data from the ExcelReadCell comand into the form on the website?

Link to comment
Share on other sites

You are mixing two techniques. The UDF accesses Excel usign the COM interface. Therefore: No need to run the exe and copy with windows.

This should do what you need:

#include <excel.au3>

$oExcel = _ExcelBookOpen("C:\temp\test.xls",1,True)        ; Open test.xls readonly and visible
$val     = _ExcelReadCell($oExcel, "C11")
ConsoleWrite($val & @CRLF)
_ExcelBookClose($oExcel)

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

The IE part of your script should look similar:

$oIE = _IECreate("your URL")
_IELoadWait($oIE)
_IEFormElementSetValue("... please see the example in the helpfile on how to get a reference to the fields in a form")
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

Allright, thanks!

I had been fiddling with the ConsoleRead option, before I read your last post.

So I read the Help File & examples, but they lost me after example 4: Set the value of an Input Type=File element.

I just need a little bit more help. However, we are nearing the end :)

The data read from the excel cell is in the STD stream (hence why I tried ConsoleRead).. But what should be the parameters to the _IEfomElementSetValue function?

Here's howfar I got, trying to paste the Data from excell into the google search form:

#include <excel.au3>

$oExcel = _ExcelBookOpen("C:\Documents and Settings\Q\Desktop\Projects\INdat\TestCleanSheet.xls",1,True) ; Open test.xls readonly and visible

$val = _ExcelReadCell($oExcel, "D5")

ConsoleWrite($val & @CRLF)

_ExcelBookClose($oExcel)

Sleep(1000)

#include <IE.au3>

$oIE = _IECreate ("www.google.com")

_IELoadWait($oIE)

_IEFormElementSetValue ($o_???)

When I got that settled, I got two last questions. I need to fill multiple forms on the same page with the data from one excel sheet.

Should I go back and forth writing data from Excel to STD to the forms, and how do I select witch form on the page to use?

Many thanks in advance for your help, and the quick responses!!

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