crystley Posted December 31, 2021 Share Posted December 31, 2021 I am trying to automate several different functions in excel through an autoit script but it wont allow me to use vba functions like .Run or .ActiveWorksheet I've seen people using them in their autoit script on the forum but autoit wont allow me to use them any help would be very appreciated. Link to comment Share on other sites More sharing options...
Nine Posted December 31, 2021 Share Posted December 31, 2021 Look at Excel UDF. Post code, if you still need help. “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 comment Share on other sites More sharing options...
crystley Posted December 31, 2021 Author Share Posted December 31, 2021 I have gotten the Excel UDFs to work but the problem comes when I try to control the excel workbooks from autoit. #include <MsgBoxConstants.au3> #include <Excel.au3> Sleep(1000) Global $bBook = "\\NeRD_LAB\Lab\Student Folders\Daylin\SiO2_68\Peak Fitting\Al2O3\Seq1\SiO2_68_D-spacings_Seq1_Al2O3(copy).xlsm" _Excel_BookAttach($bBook) $bBook.Run("DspacingsAllPeaks") here is a quick test code I was working with. The Excel udf's work fine, for example if I were to use _Excel_BookClose it will close the instance of excel if I have it open. but when I try to run the macro with .Run command it says it doesn't recognize .run as anything the same goes for if I were to try and switch the active worksheet with .ActiveWorksheet Link to comment Share on other sites More sharing options...
Nine Posted December 31, 2021 Share Posted December 31, 2021 I see. You do not understand how the UDF is working. You need to create an object and use the object to do some other actions. In your snippet, you are using a string to perform the actions, which of course won't work. You need to create the object with you attach statement (see return value). “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 comment Share on other sites More sharing options...
crystley Posted December 31, 2021 Author Share Posted December 31, 2021 Thank you! I understand how to do this now and it is working. Again thank you so much! 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