Sign in to follow this  
Followers 0
Azazel

Excel...

9 posts in this topic

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

Share this post


Link to post
Share on other sites



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]

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 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

Randall i'll put a exemple this week end

If you clic the formula bar, the script crash directly so you can't read the cell

Edited by Azazel

Share this post


Link to post
Share on other sites

#5 ·  Posted (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 by randallc

Share this post


Link to post
Share on other sites

#6 ·  Posted (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 = 1

While 1

Sleep ( 25 )

If _IsPressed("02") Then

$pos = MouseGetPos()

$actual=$oExcel.Application.ActiveCell.Address

MouseClick("left", $pos[0],$pos[1])

ExitLoop

EndIf

WEnd

MsgBox(0,"_IsPressed", "Mouse Pressed"&$actual)

Exit

Best, Randall Edited by randallc

Share this post


Link to post
Share on other sites

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 ?

Share this post


Link to post
Share on other sites

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.Add

While 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])

EndIf

WEnd

best, Randall

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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
Sign in to follow this  
Followers 0