Jump to content

Get data from Excel?


 Share

Recommended Posts

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 by azman
Link to comment
Share on other sites

1. Download from here

2. Install it to your autoitV3.1

3. then in the zip under \tests\com there are some excel exampls to go through

hope this helps :)

Edited 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

1. Download from here

2. Install it to your autoitV3.1

3. then in the zip under \tests\com there are some excel exampls to go through

hope this helps :)

<{POST_SNAPBACK}>

oh! This topic is hot!!! :D 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 = ^ ERROR

Error: Unknown function name.

Link to comment
Share on other sites

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 = ^ ERROR

Error: 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

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! :D

Link to comment
Share on other sites

I made a small and simple script can get data from a excel file( follow examples )!!!!. I will post soon!

<{POST_SNAPBACK}>

Only test!!! :D

; 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)

Exit

endif

; Mind the double :) backslashes in this line

$oExcelDoc = ObjGet("c:\\Worksheet.xls") ; Get an Excel Object from an existing filename

if 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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...