Jump to content

Excel...


Azazel
 Share

Recommended Posts

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

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

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

Link to comment
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

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

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

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
Link to comment
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 ?

Link to comment
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
Link to comment
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

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