tauruzian

Activate Excel - Not activating

11 posts in this topic

I used this code to get the excel file name and activate the file:

#include <Excel.au3>

Global $oExcel = _Excel_Open()
Global $oWorkbook = $oExcel.ActiveWorkbook
WinActivate($oWorkbook.Name)
Global $sText = WinGetTitle("")
ClipPut($sText &"::" &$oWorkbook.Name)
MsgBox(0,"Test",$sText &"::" &$oWorkbook.Name)

Initially, the code working fine in Window 7 using Excel 2013. When I try to execute the same code in Window XP using Excel 2007, the workbook did not activated.

post-82822-0-44653500-1425284362_thumb.p

Above screen shot shows that the code managed to activate the excel and get the filename in Msgbox (Window 7 and Excel 2013).

post-82822-0-06147000-1425284477.png

Above screen shot shows that the Excel not activated but only show the filename on Msgbox (Window XP and Excel 2007).

Please advice.

Share this post


Link to post
Share on other sites



With the new Excel UDF you need to call _Excel_Open to start Excel, then _Excel_BookOpen or _Excel_BookNew to open an existing/create a new workbook.

Automating the Excel GUI is a bad idea. There are COM properties to retrieve the information you need.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

With the new Excel UDF you need to call _Excel_Open to start Excel, then _Excel_BookOpen or _Excel_BookNew to open an existing/create a new workbook.

Automating the Excel GUI is a bad idea. There are COM properties to retrieve the information you need.

How to activate the minimised Excel rather than open a new one.

Share this post


Link to post
Share on other sites

Is Excel already running when you start your script?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Is Excel already running when you start your script?

Yes. But minimised by the user

Share this post


Link to post
Share on other sites

Something like this?

#include <Excel.au3>
$oExcel = _Excel_Open()
$sCaption = $oExcel.Caption
WinSetState($sCaption, "", @SW_MAXIMIZE)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

 

Something like this?

#include <Excel.au3>
$oExcel = _Excel_Open()
$sCaption = $oExcel.Caption
WinSetState($sCaption, "", @SW_MAXIMIZE)

The code working fine but fail in 1 condition. Let say I highlight some text the cell and minimised the excel and run the code. It does not working.

Share this post


Link to post
Share on other sites

Do you mean edit or just select?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Do you mean edit or just select?

Just select or just click into the cell and minimised the excel. It not working for both (2007 and 2013).

Share this post


Link to post
Share on other sites

When a cell is just selected it works fine (because at least a single cell is allways selected = the active cell).

When the cell is in edit mode then I haven't found a way to maximize the window and show thw workbook.

Is it possible to disable edit mode to solve this problem (can be done by the AutoIt script)?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

When a cell is just selected it works fine (because at least a single cell is allways selected = the active cell).

When the cell is in edit mode then I haven't found a way to maximize the window and show thw workbook.

Is it possible to disable edit mode to solve this problem (can be done by the AutoIt script)?

Yes, how do I disable the edit mode?

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