Sign in to follow this  
Followers 0
TripScott

Frustration with Excel code

5 posts in this topic

Hello all. I am fairly new to AutoIt. I am having trouble and getting frustrated with trying to "call" my Excel spreadsheet. It has been opened by another program, but has not been saved as of yet. I would like AutoIt to activate the Excel Window (my code works here) and then read the values in cells A2, B2, etc. to I2. Then I will have it go to SAP and do a bunch of other things.

The Excel UDF help files only help if you are creating a new workbook or you are opening an existing workbook. What about just using the active workbook? I have tried this, but it doesn't work.

CODE
#include <Excel.au3>

$oExcel = ObjGet("Excel.Application")

$title = WinGetTitle("Microsoft Excel", "")

WinActivate($title)

$dTitle = _ExcelReadCell($oExcel, 2, 1)

Thanks for any help!

Trip

Share this post


Link to post
Share on other sites



Hello all. I am fairly new to AutoIt. I am having trouble and getting frustrated with trying to "call" my Excel spreadsheet. It has been opened by another program, but has not been saved as of yet. I would like AutoIt to activate the Excel Window (my code works here) and then read the values in cells A2, B2, etc. to I2. Then I will have it go to SAP and do a bunch of other things.

The Excel UDF help files only help if you are creating a new workbook or you are opening an existing workbook. What about just using the active workbook? I have tried this, but it doesn't work.

CODE
#include <Excel.au3>

$oExcel = ObjGet("Excel.Application")

$title = WinGetTitle("Microsoft Excel", "")

WinActivate($title)

$dTitle = _ExcelReadCell($oExcel, 2, 1)

Thanks for any help!

Trip

If you are getting the correct excel object, you don't need to activate the window.

Test your objget line ; i.e. if not isobj($oExcel) then ....

Been quite a while since I was messing w/ excel spreadsheet automation, but I seem to recall some properties like .ActiveSheet that may be applicable to your circumstance.


Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

Share this post


Link to post
Share on other sites

This will help you:

#Include <Excel.au3>
Opt("WinTitleMatchMode", 2)

$title = WinGetTitle('Microsoft Excel')
$oExcel = _ExcelBookAttach($title, 'Title')
$dTitle = _ExcelReadCell($oExcel, 2, 1)

Best Regards BugFix  

Share this post


Link to post
Share on other sites

The Excel UDF help files only help if you are creating a new workbook or you are opening an existing workbook.

The _ExcelBookAttach() function in your help file wasn't even interesting to you?

:P


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

Thanks guys. This helped a lot!

PSaltyDS, I couldn't get the _ExcelBookAttach() function to work because it requires a file path, while the workbook doesn't have at this point. And DOH, I just realized it is optional. <smack>

Trip

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