TripScott Posted March 2, 2009 Share Posted March 2, 2009 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 Link to comment Share on other sites More sharing options...
flyingboz Posted March 2, 2009 Share Posted March 2, 2009 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!TripIf 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. Link to comment Share on other sites More sharing options...
BugFix Posted March 2, 2009 Share Posted March 2, 2009 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 Link to comment Share on other sites More sharing options...
PsaltyDS Posted March 2, 2009 Share Posted March 2, 2009 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? 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 Link to comment Share on other sites More sharing options...
TripScott Posted March 3, 2009 Author Share Posted March 3, 2009 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 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now