Jump to content

how to get two workbook objects using Excelcom_UDF?


Recommended Posts

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?

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