rilian Posted September 26, 2013 Share Posted September 26, 2013 I'm running AutoITv3 installed a week or two ago on a win7 64 bit platform. I was learning how to use the Excel.au3 UDF code. Creating a new excel doc and doing things to it works flawlessly but using _ExcelBookAttach may have a bug. I wanted to attach to an open excel file so I read the requisite help files. I got my code to attach to the workbook name I wanted in theory but I wasn't seeing anything showing up in the cells. Running my same code snippet using a new workbook instead of my existing, open excel workbook, my code ran fine. On a whim, I brought up the other excel file I had opened and the places I was writing data to w/ my autoit code were overwritten in this workbook instead of the one I targeted. Below is my code: #include <Excel.au3> Local $oExcel = _ExcelBookAttach("Microsoft Excel - samplenames_db.xlsx", "Title") For $i=2 to 41 $value=Random(100000,399999,1) _ExcelWriteCell($oExcel,$value,$i,3) next If my targeted workbook is the first workbook open, then I open another workbook, my code works on the targeted workbook flawlessly. I was able to repeat this behavior. Is this a bug somewhere in the _ExcelBookAttach code or am I doing something incorrectly? I would prefer not to have to close all my open workbooks to run a script targeted at an opened one. I should add that I got the string for the workbook title from the autoit info tool. Interesting that when I have that file open in Excel, the title reads "samplename_db.xlsx - Microsoft Excel" which is backwards from what you see in the code that was read by the info tool. Trying it the way it is displayed results in an error from the _ExcelBookAttach line. Thank you in advance for help with this. Link to comment Share on other sites More sharing options...
water Posted September 27, 2013 Share Posted September 27, 2013 The Excel UDF that comes with AutoIt only works with the active workbook and the active worksheet. My rewrite of the Excel UDF works with as many workbooks and worksheets as you like. And it is much faster. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki 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