WayneCusack Posted October 15, 2009 Share Posted October 15, 2009 I am new to AutoIt and could dearly use a little assistance. The ultimate goal is that I am trying to access an on-line database of lawyers and copy the contact information to an Excel spreadsheet. The short range goal is simply to make sure that I am accessing the Excel file without difficulty; however, I am getting an error message when I run my code. To do that, I open the Excel file and run the code below. It produces the following error message: Line 1055 (File "C:\Program Files\AutoIt3\Include\Excel.au3"); Local $iTemp = $oExcel.ActiveWorkbook.Sheets.Count Local $iTemp = $oExcel.ActiveWorkbook^ ERROR Error: The requested action with this object has failed. The sample code installed with AutoIt3 works properly to create a new workbook, but mine which accesses an existing workbook does not. The code I am using is as follows: #include <Excel.au3> #include <Array.au3> WinActivate("Microsoft Excel - Toronto Lawyers new") WinWaitActive("Microsoft Excel - Toronto Lawyers new") $sFilePath = "C:\Wayne\Jobs\Emergency Law Services\Toronto Lawyers New.xls" Local $oExcelDoc = ObjGet($sFilePath) $aArray = _ExcelSheetList($oExcelDoc) ;_ArrayDisplay($aArray, "All The WorkSheets In this WorkBook") To isolate the error I used ";" to neutralize lines - by this method I found the problem arises when the following line is run: $aArray = _ExcelSheetList($oExcelDoc) I can't figure out what I am doing wrong, and any help would be appreciated. Wayne Cusack Link to comment Share on other sites More sharing options...
BugFix Posted October 15, 2009 Share Posted October 15, 2009 (edited) If Excel is always open, you get an object reference with: $oExcel = ObjGet('', 'Excel.Application')Now can use it like known. Edited October 15, 2009 by BugFix Best Regards BugFix Link to comment Share on other sites More sharing options...
WayneCusack Posted October 15, 2009 Author Share Posted October 15, 2009 If Excel is always open, you get an object reference with: $oExcel = ObjGet('', 'Excel.Application')Now can use it like known. Link to comment Share on other sites More sharing options...
WayneCusack Posted October 15, 2009 Author Share Posted October 15, 2009 Thanks - works beautifully now. 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