tauruzian Posted March 2, 2015 Share Posted March 2, 2015 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. Above screen shot shows that the code managed to activate the excel and get the filename in Msgbox (Window 7 and Excel 2013). Above screen shot shows that the Excel not activated but only show the filename on Msgbox (Window XP and Excel 2007). Please advice. Link to comment Share on other sites More sharing options...
water Posted March 2, 2015 Share Posted March 2, 2015 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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
tauruzian Posted March 2, 2015 Author Share Posted March 2, 2015 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. Link to comment Share on other sites More sharing options...
water Posted March 2, 2015 Share Posted March 2, 2015 Is Excel already running when you start your script? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
tauruzian Posted March 2, 2015 Author Share Posted March 2, 2015 Is Excel already running when you start your script? Yes. But minimised by the user Link to comment Share on other sites More sharing options...
water Posted March 2, 2015 Share Posted March 2, 2015 Something like this? #include <Excel.au3> $oExcel = _Excel_Open() $sCaption = $oExcel.Caption WinSetState($sCaption, "", @SW_MAXIMIZE) AnonymousX 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
tauruzian Posted March 3, 2015 Author Share Posted March 3, 2015 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. Link to comment Share on other sites More sharing options...
water Posted March 3, 2015 Share Posted March 3, 2015 Do you mean edit or just select? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
tauruzian Posted March 3, 2015 Author Share Posted March 3, 2015 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). Link to comment Share on other sites More sharing options...
water Posted March 3, 2015 Share Posted March 3, 2015 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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
tauruzian Posted March 4, 2015 Author Share Posted March 4, 2015 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? Link to comment Share on other sites More sharing options...
AnonymousX Posted April 18, 2018 Share Posted April 18, 2018 On 3/2/2015 at 3:32 AM, water said: Something like this? #include <Excel.au3> $oExcel = _Excel_Open() $sCaption = $oExcel.Caption WinSetState($sCaption, "", @SW_MAXIMIZE) Thanks Water, was trying to figure this out 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