Jump to content
tauruzian

Activate Excel - Not activating

Recommended Posts

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 2019-08-19 - Version 1.4.13.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-07-24 - Version 1.3.6.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (NEW 2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Taks Scheduler (NEW 2019-10-09 - Version 0.9.0.0) - Download - General Help & Support - Wiki

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 2019-08-19 - Version 1.4.13.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-07-24 - Version 1.3.6.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (NEW 2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Taks Scheduler (NEW 2019-10-09 - Version 0.9.0.0) - Download - General Help & Support - Wiki

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)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-08-19 - Version 1.4.13.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-07-24 - Version 1.3.6.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (NEW 2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Taks Scheduler (NEW 2019-10-09 - Version 0.9.0.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki

 

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 2019-08-19 - Version 1.4.13.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-07-24 - Version 1.3.6.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (NEW 2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Taks Scheduler (NEW 2019-10-09 - Version 0.9.0.0) - Download - General Help & Support - Wiki

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 2019-08-19 - Version 1.4.13.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-07-24 - Version 1.3.6.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (NEW 2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Taks Scheduler (NEW 2019-10-09 - Version 0.9.0.0) - Download - General Help & Support - Wiki

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

×
×
  • Create New...