Azazel Posted September 29, 2005 Share Posted September 29, 2005 I have a problem that i can't arrived to solve. I'm testing the cell that is activate when a mouse clic is realised on an excel sheet .... If _IsPressed("01", $dll) Then $actual=$oExcel.ActiveCell.Address .... The problem is if i clic on the "formula bar" (after the =) The script crash I have try to use "RunErrorsFatal" option but that don't work. Could you help me ? Any idea ? Thx Aza Link to comment Share on other sites More sharing options...
Skruge Posted September 29, 2005 Share Posted September 29, 2005 Please post the rest of your code. Is your script erroring out, or just quitting? Also, the RunErrorsFatal option only applies to programs launched using Run/RunWait. [font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font] Link to comment Share on other sites More sharing options...
randallc Posted September 29, 2005 Share Posted September 29, 2005 Hi, I am interested in Excel, but do not know it well. What happens if you 1."ispressed" a rightclick formula bar, 2. read mouse location 3. read the cell 4. send left click to that mouse location? My theory is the left click might be "de-activating" the cell?... Interested to hear? Best,Randall ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
Azazel Posted September 30, 2005 Author Share Posted September 30, 2005 (edited) Hi,I am interested in Excel, but do not know it well.What happens if you 1."ispressed" a rightclick formula bar,2. read mouse location3. read the cell4. send left click to that mouse location?My theory is the left click might be "de-activating" the cell?...Interested to hear?Best,RandallRandall i'll put a exemple this week endIf you clic the formula bar, the script crash directly so you can't read the cell Edited September 30, 2005 by Azazel Link to comment Share on other sites More sharing options...
randallc Posted September 30, 2005 Share Posted September 30, 2005 (edited) Oh! Does the "Active.cell" get read OK in your script if you start it some other way than the mouse click? [i presume you have "ObjGet" or similar command before. .. etc Is your object OK - "excel.app" or workbook obj...etc?]? Randall PS I agree; I can't get mouse click to work properly?..... Edited September 30, 2005 by randallc ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
randallc Posted September 30, 2005 Share Posted September 30, 2005 (edited) this works for me;#include<ExcelCom.au3>#include <Misc.au3>$FilePath2=@ScriptDir&"\blank2.xls"$oExcel=ObjGet($FilePath2)$oExcel.Windows (1).Visible = 1;$oExcel.Worksheets (1).Activate$oExcel.ActiveSheet.Visible = 1$oExcel.Application.Visible = 1While 1 Sleep ( 25 ) If _IsPressed("02") Then $pos = MouseGetPos() $actual=$oExcel.Application.ActiveCell.Address MouseClick("left", $pos[0],$pos[1]) ExitLoop EndIfWEndMsgBox(0,"_IsPressed", "Mouse Pressed"&$actual)ExitBest, Randall Edited September 30, 2005 by randallc ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
Azazel Posted September 30, 2005 Author Share Posted September 30, 2005 This is a exemple of the script witch crash when you clic formula bar in excel #include <Misc.au3> $oExcel = Objcreate("Excel.Application") $oExcel.Visible = 1 $oExcel.WorkBooks.Add $dll = DllOpen("user32.dll") While 1 Sleep ( 90 ) If _IsPressed("01", $dll) Then $actual=$oExcel.ActiveCell.Address MsgBox(0,"",$actual) EndIf WEnd DllClose($dll) for the moment i have made a correction in this way : #include <Misc.au3> $oExcel = Objcreate("Excel.Application") $oExcel.Visible = 1 $oExcel.WorkBooks.Add $dll = DllOpen("user32.dll") While 1 Sleep ( 90 ) $focus = ControlGetFocus("Microsoft Excel") If _IsPressed("01", $dll) And $focus="EXCEL71" Then $actual=$oExcel.ActiveCell.Address MsgBox(0,"",$actual) EndIf WEnd DllClose($dll) But it's not for me the better way. Any idea to correct the crash when you click the formula bar ? Link to comment Share on other sites More sharing options...
randallc Posted September 30, 2005 Share Posted September 30, 2005 Hi,As I saud, I think the excel app does NOT have any "active Cell" during "formula bar" mode just as you cannot shut the window in that mode by, say, clicking on top right "X"); threefore, you have to get the "active Cell" before the left click is sent; eg as below, use the right click.)#include <Misc.au3>$oExcel = Objcreate("Excel.Application")$oExcel.Visible = 1$oExcel.WorkBooks.AddWhile 1 Sleep ( 20 ) $focus = ControlGetFocus("Microsoft Excel") If _IsPressed("01") And $focus="EXCEL71" Then $actual=$oExcel.ActiveCell.Address MsgBox(0,"On Left click","On Left click="&$actual) EndIf If _IsPressed("02") Then ;Maybe you can set a "focus" for formula control only here to avoid errors if you miss the formula bar! $pos = MouseGetPos() $actual=$oExcel.ActiveCell.Address MsgBox(0,"On Right click","On Right click="&$actual) MouseClick("left", $pos[0],$pos[1]) EndIfWEndbest, Randall ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
Azazel Posted October 1, 2005 Author Share Posted October 1, 2005 Problem solved... #include <Misc.au3> Global $actual2 $oExcel = Objcreate("Excel.Application") $oExcel.Visible = 1 $oExcel.WorkBooks.Add $title=WinGetTitle("") While WinExists($title) Sleep ( 20 ) $focus = ControlGetFocus("Microsoft Excel") If _IsPressed("01") And $focus="EXCEL71" Then $actual=$oExcel.ActiveCell.Address if $actual2<>$actual Then $actual2=$actual if StringLeft($actual,2)="$G" Then MsgBox(0,"","Select") EndIf EndIf WEnd Thx to all 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