gauravvogue Posted February 19, 2014 Posted February 19, 2014 hi.. i have two queries 1... How to run macro using autoit? I have used the below code but its giving error as unable to parse line......is that the right code ? I am opening a macro file name"Tmacro" saved in C drive folder named Market $oExcel = ObjCreate("Excel.Application") $oExcel.WorkBooks.Open($C:MarketTmacro.xlsm) $oExcel.Run("Macro1") "more code" 2. Whenever the macro execution gets completed then i want to execute further commands in my autoit script and dont want to use sleep function?????? please help
water Posted February 19, 2014 Posted February 19, 2014 Needs to be: $oExcel.WorkBooks.Open("C:\Market\Tmacro.xlsm") 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
water Posted February 19, 2014 Posted February 19, 2014 Doesn't "Run" wait until the called macro has finished? So you simply call "Run" multiple times in your 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
gauravvogue Posted February 19, 2014 Author Posted February 19, 2014 hi i have used the below command to open my excel macro file _ExcelBookOpen ("C:MarketTmacro.xlsm")( getting successful) but can u tell me how would i run my macro from here... as i have used .Run("Macro1") but it is showing an error as object referenced outside a "with " statement
water Posted February 19, 2014 Posted February 19, 2014 (edited) $oExcel = _ExcelBookOpen ("C:\Market\Tmacro.xlsm") $oExcel.Run("Macro1") $oExcel.Run("Macro2") ... Edited February 19, 2014 by water 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
gauravvogue Posted February 19, 2014 Author Posted February 19, 2014 thanks sir! It was getting successful. Just one last query How can i program that" I want to wait until the macro gets finished"........? actually i dont want to include" SLEEP command".................. sometimes macro run 30 seconds and sometimes 50 seconds......
Solution water Posted February 19, 2014 Solution Posted February 19, 2014 MSDN says: "The Run method returns whatever the called macro returns" So I think the AutoIt script will wait until the macro has finished and then processes the next statement. 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
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