Jump to content

AutoIT & Excel


Recommended Posts

Hi Everyone!

New AutoIt user, not a programmer in anyway however i am an excel power user and do know enough VBA to create macros etc however i have only ever taught myself and am having quite some trouble with AutoIt..

I am moving onto AutoIt now to automate alot of my excel macros i created for database manipulation but cannot for the life of me understand the coding... Have googled and youtubed for hours trying to find any sort of info i can... I have even read the UDF syntax however when i to do something, it never works...

What im trying to do:

I need to be able to open excel file, pull data out, open & paste into a datauploading program, open the CRM program and login, run the datauploading program script and then log out, close everything.

What i don't understand:

#include <Excel.au3>
_ExcelBookOpen($sFilePath [, $fVisible = 1 [, $fReadOnly = False [, $sPassword = "" [, $sWritePassword = ""]]]])

Local $sFilePath1 = @ScriptDir & "Test.xls" ;This file should already exist
Local $oExcel = _ExcelBookOpen($sFilePath1)

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

This is the example from the AutoIt Help and i dont understand where the @scriptDir came from? where the file path goes etc.. i know once i understand how it works i will be able to manipulate it like VBA but initally just dont understand.. Like i dont understand which is commands and what parts i change to suit me specifically...

Any tips/advice/help would be muchly appreciated. - Apologies if this is a stupid post i just cannot find good information on AutoIt working with Excel.

Edited by 13lack13lade
Link to comment
Share on other sites

Is this statement in your script?

_ExcelBookOpen($sFilePath [, $fVisible = 1 [, $fReadOnly = False [, $sPassword = "" [, $sWritePassword = ""]]]])

That's just the syntax description. Brackets denote optional parameters. So the above line should - if you use all default parameters - look like:

_ExcelBookOpen($sFilePath, 1, False, "", "")

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

No i was simply using this as an example because obviously im going to need to open the excel file and thought this would be a good start.

What i mean is $sFilePath would that mean that its _ExcelBookOpen($sC:/blahblah/blah.xls) or is $sFilePath the command? just unsure on how to use the syntax correctly 

Link to comment
Share on other sites

$sFilePath is a variable.

Either use

_ExcelBookOpen("C:\blahblah\blah.xls")

or

$sFilePath = "C:\blahblah\blah.xls"
_ExcelBookOpen($sFilePath)

And yes, you need to read the help file or some tutorials about the basics of AutoIt.

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

BTW: The Excel UDF that comes with AutoIt doesn't support the "new" formats (xlsx etc.), only okrs on the active worksheet and has some other limitations.

If you like you can test my rewrite of the UDF (still an Alpha version). For download please see my signature.

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

Thank you for your help, i will definately give the UDF a go and spend sometime going through the tutorials.

I think i was just over complicating things and the code is abit intimidating at first but i look forward to figuring it out, it seems the possibilities for automation are endless!

 

Thanks again.

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