diff 1 Posted August 4, 2020 Share Posted August 4, 2020 Hi, was searching in the forum for solution but didn't found anything similar, so my problem is that after user selects Excel file the other _Excel_ functions doesn't work. I created a logic, that if any user changes file name or file location then has option to select the file location manually with FileDialogOpen This is how it looks: $fileLocation = "C:\Users\Desktop\File.xlsx" If Not FileExists($fileLocation) Then MsgBox(48, "File not found", "File not found, please select") FileOpenDialog("Select file", "C:\Users\", "Excel (*.xlsx*)") EndIf $oExcel = _Excel_Open(1, 1, 1, 1, 1) $xlBook = _Excel_BookOpen($oExcel, $fileLocation) $xlBook.Sheets("Users").Activate .....and continues other $xlBook.Sheets functions....... So if the File.xlsx is found on this location everything works correctly the sheet .Active works as expected, but if the File.xlsx not found and user selects in other directory same file, then all my $xlBook.Sheets functions doesn't work and crashes on first one which is $xlBook.Sheets("Users").Activate What did I missed? Thank you for the help Link to post Share on other sites
seadoggie01 301 Posted August 4, 2020 Share Posted August 4, 2020 Well... $fileLocation never changes. You probably meant to set it equal to the result of the FileOpenDialog All my code provided is Public Domain... but it may not work. Use it, change it, break it, whatever you want. Spoiler My Humble Contributions:Personal Function Documentation - A personal HelpFile for your functionsAcro.au3 UDF - Automating Acrobat ProToDo Finder - Find #ToDo: lines in your scriptsUI-SimpleWrappers UDF - Use UI Automation more Simply-erKeePass UDF - Automate KeePass, a password manager Link to post Share on other sites
Nine 1,606 Posted August 4, 2020 Share Posted August 4, 2020 (edited) If you had put some error handling after each statements, you would have found out what was the problem. Look in help file under Excel UDF to learn how to insert messages that check for errors (in all examples there is error handling). Edited August 4, 2020 by Nine “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 GIF Animation (cached) Screen Scraping Link to post Share on other sites
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