jc0r Posted November 7, 2012 Share Posted November 7, 2012 Hi all What i am trying to do i believe is relatively simple. I have an Excel workbook open call test.xls and i would like to get AutoIt to execute one of the macros stored wiithin the workbook. The macro is called "just1" I created the following code: $oExcel.run("just1") but get the following error: >"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\jc0r\Desktop\test.au3" C:\Users\jc0r\Desktop\test.au3 (1) : ==> Expected a "=" operator in assignment statement.: $oExcel.run("just1") $oExcel^ ERROR >Exit code: 1 Time: 0.238 Any ideas please? Many thanks jc0r Link to comment Share on other sites More sharing options...
jc0r Posted November 7, 2012 Author Share Posted November 7, 2012 Nope sorry same error: >"C:Program FilesAutoIt3SciTE..autoit3.exe" /ErrorStdOut "C:Usersjc0rDesktoptest.au3" C:Usersjc0rDesktoptest.au3 (1) : ==> Expected a "=" operator in assignment statement.: $oExcel.run = "just1" $oExcel^ ERROR >Exit code: 1 Time: 0.225 I dont know if it matters but i am using Excel 2003 and i do not have anything else in my script other than that one line. I am not sure if i need to reference to the workbook or not? Link to comment Share on other sites More sharing options...
Andreik Posted November 7, 2012 Share Posted November 7, 2012 In this case the error is clear, you don't have an excel object. Use Excel UDF to open your document and then run the macro. When the words fail... music speaks. Link to comment Share on other sites More sharing options...
jc0r Posted November 7, 2012 Author Share Posted November 7, 2012 This is not possible, i need to Excel document to already be open and i use AutoIt to call macros from within the workbook. Do you know if this is possible please? Link to comment Share on other sites More sharing options...
Andreik Posted November 7, 2012 Share Posted November 7, 2012 Look in help file at _ExcelBookOpen() function. This function will return you an object that allow run method to run your macro. When the words fail... music speaks. Link to comment Share on other sites More sharing options...
water Posted November 7, 2012 Share Posted November 7, 2012 Use function _ExcelBookAttach of the Excel UDF to attach to an already open workbook. Then you can run the macro. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
jc0r Posted November 7, 2012 Author Share Posted November 7, 2012 Many thanks for you help so far. I only have 2 posts left for today as i am a new member but i am struggling with what you've provided so far. This is my current script however it just seems to open another copy of the workbook and not do anything #include <Excel.au3> #include <File.au3> Local $sFilePath = "c:test.xls" _ExcelBookOpen($sFilePath) Local $oExcel = _ExcelBookAttach($sFilePath) $oExcel.run("just1") I do not want it to open another workbook, as you stated, i want it to attach to the existing one but when i remove the line: _ExcelBookOpen($sFilePath) The whole thing breaks down. This seems tricky when all i want to do is execute a macro in Excel? Thanks Link to comment Share on other sites More sharing options...
water Posted November 7, 2012 Share Posted November 7, 2012 I would use: #include <Excel.au3> Global $sFilePath = "c:test.xls" Global $oExcel = _ExcelBookAttach($sFilePath) ; Returns the workbook object $oExcel.parent.run("just1") ; Run method needs the application object My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
jc0r Posted November 7, 2012 Author Share Posted November 7, 2012 I cannot thank you enough, this worked just as i desired. I am not allowed to post anymore today as i am new so thanks for taking the time with my problem. Regards Link to comment Share on other sites More sharing options...
water Posted November 7, 2012 Share Posted November 7, 2012 Glad to be of service My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
envirowiz Posted September 26, 2013 Share Posted September 26, 2013 Hello, I am not able to DL the Beta 2 Excel Rewrite zip file: Is there another link? Link to comment Share on other sites More sharing options...
water Posted September 26, 2013 Share Posted September 26, 2013 Thre have been 40 downloads. And so far I haven't heard of a problem. Do you get an error message or is the download incomplete? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
envirowiz Posted October 15, 2013 Share Posted October 15, 2013 I found the problem - corporate firewall. Thanks. Link to comment Share on other sites More sharing options...
water Posted October 15, 2013 Share Posted October 15, 2013 Glad the problem could be solved My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
envirowiz Posted November 20, 2013 Share Posted November 20, 2013 Water, I am using the $oExcel.parent.Run("MacroName") as you stated, but get this error message: ==> The requested action with this object has failed.: $oExcel.parent.Run("ADRReport") $oExcel.parent.Run("ADRReport")^ ERROR Is something else needed at the end of the script line? Link to comment Share on other sites More sharing options...
water Posted November 20, 2013 Share Posted November 20, 2013 Can you add a COM error handler so we get more detailed error information? The help file for ObjEvent shows what you need to do. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki 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