dreivilo47 Posted July 18, 2021 Share Posted July 18, 2021 @SW_MINIMIZE does not work here. What's wrong? ShellExecute("Excel.exe", "C:\test\test.xlsx", "", "", @SW_MINIMIZE) Link to comment Share on other sites More sharing options...
Nine Posted July 18, 2021 Share Posted July 18, 2021 Works for me ! “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
TheXman Posted July 18, 2021 Share Posted July 18, 2021 (edited) If Excel is the default app for .xlsx files on your PC, then you can just use: ShellExecute("C:\test\test.xlsx", "", "", "", @SW_MINIMIZE) if not, then you could try: (assumes excel.exe can be found in the PATH) ShellExecute("Excel.exe", '"C:\test\test.xlsx"', "", "", @SW_MINIMIZE) Edited July 18, 2021 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
leuce Posted July 19, 2021 Share Posted July 19, 2021 (edited) Neither of these two options work for me either: ShellExecute("Excel.exe", '"C:\Users\My User\Desktop\Book1.xlsx"', "", "", @SW_MINIMIZE) ShellExecute('"C:\Users\My User\Desktop\Book1.xlsx"', "", "", "", @SW_MINIMIZE) Windows 10 latest, Excel 365. It opens the file in Excel, but Excel is not minimized. @SW_MAXIMIZE does work. The only way I can ensure that Excel is minimized is by minimizing it separately: ShellExecute ("Excel.exe", '"C:\Users\My User\Desktop\Book1.xlsx"', "", "") WinActivate ("Book1.xlsx - Excel", "") WinWaitActive ("Book1.xlsx - Excel", "") Send ("#{DOWN}") or: ShellExecute ("Excel.exe", '"C:\Users\My User\Desktop\Book1.xlsx"', "", "") WinWaitActive ("Book1.xlsx - Excel", "") WinSetState ("Book1.xlsx - Excel", "", @SW_MINIMIZE) Edited July 19, 2021 by leuce dreivilo47 1 Link to comment Share on other sites More sharing options...
Danp2 Posted July 19, 2021 Share Posted July 19, 2021 Does it work if you just load Excel without the spreadsheet? Have you tried using the Excel UDF to open the spreadsheet instead? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
dreivilo47 Posted July 25, 2021 Author Share Posted July 25, 2021 On 7/18/2021 at 3:33 PM, TheXman said: If Excel is the default app for .xlsx files on your PC, then you can just use: ShellExecute("C:\test\test.xlsx", "", "", "", @SW_MINIMIZE) if not, then you could try: (assumes excel.exe can be found in the PATH) ShellExecute("Excel.exe", '"C:\test\test.xlsx"', "", "", @SW_MINIMIZE) Neither of them works. Excel is my default app for .xlsx files on my PC. Link to comment Share on other sites More sharing options...
dreivilo47 Posted July 25, 2021 Author Share Posted July 25, 2021 On 7/19/2021 at 11:19 PM, Danp2 said: Does it work if you just load Excel without the spreadsheet? Have you tried using the Excel UDF to open the spreadsheet instead? This is working: ShellExecute("Excel.exe", "", "", "", @SW_MINIMIZE) Excel UDF? Link to comment Share on other sites More sharing options...
Danp2 Posted July 25, 2021 Share Posted July 25, 2021 3 minutes ago, dreivilo47 said: Excel UDF? See the topic Excel Management in the help file. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
dreivilo47 Posted August 1, 2021 Author Share Posted August 1, 2021 On 7/25/2021 at 10:31 PM, Danp2 said: See the topic Excel Management in the help file. I have seen the topic "Excel Management" in the help file. It seems that there is no "@SW_MINIMIZE" with "_Excel_BookOpen". Link to comment Share on other sites More sharing options...
Danp2 Posted August 1, 2021 Share Posted August 1, 2021 @dreivilo47True, but you can use _Excel_Open to launch a hidden copy of Excel. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
dreivilo47 Posted August 9, 2021 Author Share Posted August 9, 2021 On 8/1/2021 at 10:23 PM, Danp2 said: @dreivilo47True, but you can use _Excel_Open to launch a hidden copy of Excel. @Danp2 Thank you for the information. How can you do that? Link to comment Share on other sites More sharing options...
Danp2 Posted August 9, 2021 Share Posted August 9, 2021 @dreivilo47Suggest that you take a look at the help file entry for _Excel_Open Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
dreivilo47 Posted August 16, 2021 Author Share Posted August 16, 2021 On 8/9/2021 at 10:53 PM, Danp2 said: @dreivilo47Suggest that you take a look at the help file entry for _Excel_Open @Danp2I have looked at the help file entry for "_Excel_Open". This is the code to launch a hidden copy of Excel: #include <Excel.au3> Global $bVisible = True Global $sWorkbook = "C:\test\test.xlsx" $oWorkbook = _Excel_BookOpen(_Excel_Open($bVisible = False), $sWorkbook) After that, what to do to minimize the file? Link to comment Share on other sites More sharing options...
Danp2 Posted August 16, 2021 Share Posted August 16, 2021 20 minutes ago, dreivilo47 said: $oWorkbook = _Excel_BookOpen(_Excel_Open($bVisible = False), $sWorkbook) This line of code doesn't appear to be correct. I would suggest separating into two lines so that you could check for errors -- #include <Excel.au3> Global $bVisible = False Global $sWorkbook = "C:\test\test.xlsx" Global $oExcel = _Excel_Open($bVisible) Global $oWorkbook = _Excel_BookOpen($oExcel, $sWorkbook) I was assuming that all of the related windows are hidden if Excel is launched hidden. Is that incorrect? dreivilo47 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Solution yuser Posted August 17, 2021 Solution Share Posted August 17, 2021 Executing excel with a parameter and running excel THEN opening a file is slightly different. When a workbook is opened directly with a parameter, it's like two windows were handled. The second window does not inhert the minimized flag that was assigned to the initial one. It's just the weird way that excel handles windows. To run a workbook "minimized", you can use this trick to run excel hidden, open a file, minimize the window, then set show flag. #include <Excel.au3> $sFilePath = "C:\test\test.xlsx" $sFileName = StringRight($sFilePath,StringLen($sFilePath)-StringInStr($sFilePath,"\",0,-1)) $oExcel = _Excel_Open(0) $oWorkbook = _Excel_BookOpen($oExcel,$sFilePath) Do Sleep(5) Until WinExists($sFileName & " - Excel") WinSetState($sFileName & " - Excel","",@SW_MINIMIZE) $oExcel.Visible = True dreivilo47 1 Link to comment Share on other sites More sharing options...
dreivilo47 Posted August 22, 2021 Author Share Posted August 22, 2021 On 8/16/2021 at 9:50 PM, Danp2 said: This line of code doesn't appear to be correct. I would suggest separating into two lines so that you could check for errors -- #include <Excel.au3> Global $bVisible = False Global $sWorkbook = "C:\test\test.xlsx" Global $oExcel = _Excel_Open($bVisible) Global $oWorkbook = _Excel_BookOpen($oExcel, $sWorkbook) I was assuming that all of the related windows are hidden if Excel is launched hidden. Is that incorrect? Ok, thank you. No errors here. "test.xlsx" is hidden, Excel too. Excel is only visible in the Task Manager. Link to comment Share on other sites More sharing options...
dreivilo47 Posted August 22, 2021 Author Share Posted August 22, 2021 On 8/17/2021 at 2:06 AM, yuser said: Executing excel with a parameter and running excel THEN opening a file is slightly different. When a workbook is opened directly with a parameter, it's like two windows were handled. The second window does not inhert the minimized flag that was assigned to the initial one. It's just the weird way that excel handles windows. To run a workbook "minimized", you can use this trick to run excel hidden, open a file, minimize the window, then set show flag. #include <Excel.au3> $sFilePath = "C:\test\test.xlsx" $sFileName = StringRight($sFilePath,StringLen($sFilePath)-StringInStr($sFilePath,"\",0,-1)) $oExcel = _Excel_Open(0) $oWorkbook = _Excel_BookOpen($oExcel,$sFilePath) Do Sleep(5) Until WinExists($sFileName & " - Excel") WinSetState($sFileName & " - Excel","",@SW_MINIMIZE) $oExcel.Visible = True This is working here. The code of @leuce too. My problem is solved. Thanks for your help and support. 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