Jump to content

Changing between Excel files


fx11
 Share

Go to solution Solved by michaelslamet,

Recommended Posts

Hi, members!

 

I have just started learning about making AutoIt scripts.

I would like to copy datas from one Excel file to another.

I use Excel 2003.

I have two files named: MyExFile1.xls and MyExFile2.xls

 

First I open all the two files manually. MyExFile1.xls is the active window.

 

When I use WinActivate("MyExFile2.xls") function in a script,

it does not make switch from MyExFile1.xls to MyExFile2.xls.

MyExFile1.xls stays the active window and MyExFile2.xls DOES NOT become active.

 

How can I solve this?

Thanks.

Link to comment
Share on other sites

Hi michaelslamet!

Thanks for your help. Now it works as I wish. And it does it relatively fast.

Here is what I've tried:

contents of MyExFile1.xls in column A:
1
2
3
4

contents of MyExFile2.xls in column A:
828210
828211
828212
828213
828214
828215
828216
828217
828218
828219
828220

--------------------------------------------------------------------------------

My Script:

AutoItSetOption("WinTitleMatchMode", 2) ;2 = Match any substring in the title

WinActivate("MyExFile1.xls")
WinWaitActive("MyExFile1.xls")

Send("btype")
Send("{ENTER}")

WinActivate("MyExFile2.xls")
WinWaitActive("MyExFile2.xls")

Send("ordnum")
Send("{ENTER}")

--------------------------------------------------------------------------------

Results after running it:

contents of MyExFile1.xls in column A:
btype
2
3
4

contents of MyExFile2.xls in column A:
ordnum
828211
828212
828213
828214
828215
828216
828217
828218
828219
828220

 

Link to comment
Share on other sites

In my signature you'll find the link to the rewrite of the Excel UDF (this will become part of the next AutoIt version).

Function _Excel_RangeCopyPaste should allow to copy a range of cells from one workbook to another. See example 2 in the example 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

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