andy09 Posted February 3, 2009 Share Posted February 3, 2009 Hi, I would like to automate the following: 1)Open excel file "test.xls" 2)Copy a column from that file 3) Check if the excel file "apa.xls" is open. If yes, activate it, if no open it 4) Paste the data into a new row 5) Close excel file "test.xls" I've succeded with 1) and 2) and 4) but I need help with something for no 3) I've used _ExcelBookOpen but it just opens a new copy of the excel file each time I call it. This is the code so far: CODE#include <Array.au3> #include <Excel.au3> $sFilePath1 = "C:\Test.xls" $oExcel = _ExcelBookOpen($sFilePath1) If @error = 1 Then MsgBox(0, "Error!", "Unable to Create the Excel Object") Exit ElseIf @error = 2 Then MsgBox(0, "Error!", "File does not exist - Shame on you!") Exit EndIf $aArray1 = _ExcelReadArray($oExcel, 2, 4, 70, 1) ;Direction is Vertical ;the following just opens up a new copy of apa.xls each time... Could Excelsheetactivate work? how? other ideas? $sFilePath2 = "C:\apa.xls" ;This file should already exist $oExcel2 = _ExcelBookOpen($sFilePath2) _ExcelWriteArray($oExcel2, 1, 1, $aArray1) Link to comment Share on other sites More sharing options...
PsaltyDS Posted February 3, 2009 Share Posted February 3, 2009 Hi,I would like to automate the following:1)Open excel file "test.xls" 2)Copy a column from that file3) Check if the excel file "apa.xls" is open. If yes, activate it, if no open it4) Paste the data into a new row5) Close excel file "test.xls"I've succeded with 1) and 2) and 4) but I need help with something for no 3)I've used _ExcelBookOpen but it just opens a new copy of the excel file each time I call it.This is the code so far:CODE#include <Array.au3>#include <Excel.au3>$sFilePath1 = "C:\Test.xls" $oExcel = _ExcelBookOpen($sFilePath1)If @error = 1 Then MsgBox(0, "Error!", "Unable to Create the Excel Object") ExitElseIf @error = 2 Then MsgBox(0, "Error!", "File does not exist - Shame on you!") ExitEndIf$aArray1 = _ExcelReadArray($oExcel, 2, 4, 70, 1) ;Direction is Vertical;the following just opens up a new copy of apa.xls each time... Could Excelsheetactivate work? how? other ideas?$sFilePath2 = "C:\apa.xls" ;This file should already exist$oExcel2 = _ExcelBookOpen($sFilePath2)_ExcelWriteArray($oExcel2, 1, 1, $aArray1)3) _ExcelBookAttach() 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...
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