azman Posted March 12, 2005 Share Posted March 12, 2005 (edited) Hi! I made a script to get get data from excel and insert tinto a array. However, event "press Ctrl C" not work correctly! It can't get data in a cell?? Here is my script: RUN("c:\Program Files\Microsoft Office\Office10\EXCEL.EXE") WinWaitActive("Microsoft Excel - Book1") Send("^o") WinWaitActive("Open","MSO Generic Control Container") Send("C:\data.xls") Send("{ENTER}") WinWaitActive("Microsoft Excel - data") Send("^{HOME}") $flag1=0 $count=0 $str="" While $flag1=0 Send("^C") $str=ClipGet() Sleep(2000) Msgbox(0, "MessageBox", $str) If $str="END" Then $flag1=1 Else $count=$count+1 $maso[$count]=$str Send("{DOWN}") Sleep(2000) $flag1=0 EndIf WEnd Thanks!!! Edited March 12, 2005 by azman Link to comment Share on other sites More sharing options...
bshoenhair Posted March 12, 2005 Share Posted March 12, 2005 Look Here for recomendationhttp://www.autoitscript.com/forum/index.php?showtopic=9309 Link to comment Share on other sites More sharing options...
azman Posted March 14, 2005 Author Share Posted March 14, 2005 The best solution is to use Excel VBA with AutoItX.dll and you will not have this issue.How to use Excel with AutoItX? I searched but can find any topic about this issue.Thanks for help! Link to comment Share on other sites More sharing options...
igmeou Posted March 14, 2005 Share Posted March 14, 2005 (edited) 1. Download from here2. Install it to your autoitV3.13. then in the zip under \tests\com there are some excel exampls to go throughhope this helps Edited March 14, 2005 by igmeou [font="Arial"]Thanks[/font]If @error = me Then $sorry Else Do $clarifyMe Until $meClear EndIF MsgBox(0,"Special Message!","Special Thanks to " & $allHadReplied,$Forever) Link to comment Share on other sites More sharing options...
azman Posted March 14, 2005 Author Share Posted March 14, 2005 1. Download from here2. Install it to your autoitV3.13. then in the zip under \tests\com there are some excel exampls to go throughhope this helps <{POST_SNAPBACK}>oh! This topic is hot!!! Thanks a lot, I unzip and run examples but these script(ExcelAutomationTest...) , contain error!!!Ex:Line 6 (File "C:\Documents and Settings\Administrator\Desktop\AutoIt3.1.0.15I\tests\com\ExcelAutomationTest.au3"):$MyExcel = ObjCreate("Excel.Application") ; Create an Excel Object$MyExcel = ^ ERRORError: Unknown function name. Link to comment Share on other sites More sharing options...
igmeou Posted March 14, 2005 Share Posted March 14, 2005 oh! This topic is hot!!! Thanks a lot, I unzip and run examples but these script(ExcelAutomationTest...) , contain error!!!Ex:Line 6 (File "C:\Documents and Settings\Administrator\Desktop\AutoIt3.1.0.15I\tests\com\ExcelAutomationTest.au3"):$MyExcel = ObjCreate("Excel.Application") ; Create an Excel Object$MyExcel = ^ ERRORError: Unknown function name.I think didn't unzip the files to your autoitV3.1 install folder.Which means you had to overwrite the downloaded files into the folder which you install your AutoIT version 3.1. (Default: C:\Program Files\AutoIt3\) [font="Arial"]Thanks[/font]If @error = me Then $sorry Else Do $clarifyMe Until $meClear EndIF MsgBox(0,"Special Message!","Special Thanks to " & $allHadReplied,$Forever) Link to comment Share on other sites More sharing options...
azman Posted March 14, 2005 Author Share Posted March 14, 2005 Wow!!!! It worked! But when I click OK then: --------------------------- AutoIt Error --------------------------- Line 48 (File "C:\Program Files\AutoIt3\tests\com\ExcelFastTest.au3"): $MyExcel.activeworkbook.saved = 1 ; To prevent 'yes/no' questions from Excel $MyExcel.activeworkbook^ ERROR Error: The requested action with this object has failed. --------------------------- OK --------------------------- But it is not problem ! I thinks it will help me a lot! Thanks for your help! Link to comment Share on other sites More sharing options...
azman Posted March 16, 2005 Author Share Posted March 16, 2005 I made a small and simple script can get data from a excel file( follow examples )!!!!. I will post soon! Link to comment Share on other sites More sharing options...
azman Posted March 16, 2005 Author Share Posted March 16, 2005 I made a small and simple script can get data from a excel file( follow examples )!!!!. I will post soon!<{POST_SNAPBACK}>Only test!!! ; Excel file Automation Example;; Based on AutoItCOM version 3.1.0;; Beta version 06-02-2005; An Excel file with filename Worksheet.xls must be created in the root directory; of the C:\ drive in order for this example to work.$FileName="C:\Worksheet.xls"if not FileExists($FileName) then Msgbox (0,"Excel File Test","Can't Open, because you didn't create the Excel file "& $FileName) Exitendif; Mind the double backslashes in this line $oExcelDoc = ObjGet("c:\\Worksheet.xls") ; Get an Excel Object from an existing filenameif IsObj($oExcelDoc) then MsgBox(0,"","Value(1,1)= " &$oExcelDoc.activesheet.cells(1,1).value)else Msgbox (0,"Excel File Test","Error: Could not open "& $FileName & " as an Excel Object.")endif 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