Azazel Posted January 24, 2009 Share Posted January 24, 2009 (edited) Hi everybody,My goal is to write and read some datas in a excel sheet .I want to read the cell (1,2) and use this data to fill the name of the book in "Save as"I'm in front of 2 errors and crashesI use Autoit v3.2.13.13 (beta)Souce code :#include <Excel.au3> #include <Date.au3> $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc"); Install a custom error handler $date=@MDAY&"/"&@MON&"/"&@YEAR $oExcel = _ExcelBookNew() _ExcelWriteCell($oExcel, $date, 1, 1);Write to the Cell while 1 $name = _ExcelReadCell($oExcel, 1, 2) if $name<>"" Then ExitLoop EndIf Sleep(500) WEnd WinWait("Save As","") ControlSetText( "Save As", "", "[CLASS:RichEdit20W; INSTANCE:2]", @ScriptDir&"\"&@YEAR&"\SEM "&_WeekNumberISO()&$name&".xls") Exit Func MyErrFunc() ;Avoid CRASH EndFunc ;==>MyErrFuncFirst Crash :If in don't use a "Install a custom error handler" when i start to fill the cell (1,2) i have this message :C:\Program Files\AutoIt3\beta\Include\Excel.au3 (685) : ==> The requested action with this object has failed.:Return $oExcel.Activesheet.Cells($sRangeOrRow, $iColumn).ValueReturn $oExcel.Activesheet^ ERRORI use a error handler to solve the problemSecond crash :If i use the error handler and i close the Excel sheet before opening "Save as" i have this message :C:\Program Files\AutoIt3\beta\Include\Excel.au3 (685) : ==> Missing right bracket ')' in expression.:Return $oExcel.Activesheet.Cells($sRangeOrRow, $iColumn).ValueReturn ^ ERRORPlease help me for debugging my scriptBest regardsMarc Edited January 24, 2009 by Azazel Link to comment Share on other sites More sharing options...
BrettF Posted January 24, 2009 Share Posted January 24, 2009 Hi, Is the value of cell 1,2 set by you the user or is it already present in the excel file? From what I can see, excel doesn't like it if you read a cell while it is being updated, I'll have a look to see if there's a way to test if the cell is selected. Brett Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Azazel Posted January 24, 2009 Author Share Posted January 24, 2009 Hi,Is the value of cell 1,2 set by you the user or is it already present in the excel file?From what I can see, excel doesn't like it if you read a cell while it is being updated, I'll have a look to see if there's a way to test if the cell is selected.BrettHi, The cell 1,2 is set by the user When the Excel sheet is start this cell is blankBest regards Link to comment Share on other sites More sharing options...
BrettF Posted January 24, 2009 Share Posted January 24, 2009 Why not write it using AutoIt then? Just a simple matter of using Input box etc.Otherwise we need to have this then:But not too sure how to implement it http://msdn.microsoft.com/en-us/library/aa...office.11).aspx Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Azazel Posted January 24, 2009 Author Share Posted January 24, 2009 Why not write it using AutoIt then? Just a simple matter of using Input box etc.Otherwise we need to have this then:But not too sure how to implement it http://msdn.microsoft.com/en-us/library/aa...office.11).aspxMy collegues use this excel sheet to send spare parts to customers, i don't want to interract with there job with a input boxi just want to read the datas they fill in to generate the "Save as" name Link to comment Share on other sites More sharing options...
Azazel Posted January 25, 2009 Author Share Posted January 25, 2009 No more help ? Link to comment Share on other sites More sharing options...
Bowmore Posted January 25, 2009 Share Posted January 25, 2009 (edited) My collegues use this excel sheet to send spare parts to customers, i don't want to interract with there job with a input boxi just want to read the datas they fill in to generate the "Save as" nameFrom your description of what you are trying to achieve, I would suggest that this is not a job for AutoiIt. I would be easier and simpler to code a function to do this using Excels own VBA to intercept the save event. Edited January 25, 2009 by Bowmore "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Link to comment Share on other sites More sharing options...
Azazel Posted January 25, 2009 Author Share Posted January 25, 2009 From your description of what you are trying to achieve, I would suggest that this is not a job for AutoiIt. I would be easier and simpler to code a function to do this using Excels own VBA to intercept the save event.I understant your opinion, unfortunatly, the script i put here is a small part of a bigger AutoIt programSo i need your help to make it worksThanks a lotMarc 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