Sign in to follow this  
Followers 0
sigil

how to get two workbook objects using Excelcom_UDF?

2 posts in this topic

I'm trying to use Excelcom_UDF to attach to 2 workbooks at the same time, so that I can compare their contents and transfer data back and forth. But it seems like _ExcelAttach() changes all Excel objects to the most recently called workbook, so I can't have two separate objects.

Here's the code I'm using:

#include <excelcom_udf.au3>
#include <array.au3>

$frompath="path\book1.xls"
$topath="path\book2.xls"

$fromobj=_excelattach($frompath)
$fromarray=_excelreadarray($fromobj,2,1,252,1)
$toobj=_excelattach($topath)
_arraydisplay($fromarray)

This works fine, it displays data from the workbook specified by $frompath. But if I put the $fromarray assignment after the $toobj assignment, like this:

#include <excelcom_udf.au3>
#include <array.au3>

$frompath="path\book1.xls"
$topath="path\book2.xls"

$fromobj=_excelattach($frompath)
$toobj=_excelattach($topath)
$fromarray=_excelreadarray($fromobj,2,1,252,1)
_arraydisplay($fromarray)

it displays data from the $topath workbook. Apparently calling _excelattach($topath) affects the object i created using _excelattach($frompath) as well. How can I make objects for two different Excel sheets?

Share this post


Link to post
Share on other sites



Use the standard UDF Excel.au3 that comes with AutoIt and _ExcelBookAttach().

:idea:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
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
Sign in to follow this  
Followers 0