mikep56 0 Posted October 18, 2007 Hi All, I have been struggling to figure out how to run an Excel macro on an Excel spreadsheet from an AutoIt script. I have looked over the forum and the help files without success. Thanks for any help that can be tossed my way. Regards, Mike Share this post Link to post Share on other sites
PsaltyDS 41 Posted October 18, 2007 Hi All,I have been struggling to figure out how to run an Excel macro on an Excel spreadsheet from an AutoIt script. I have looked over the forum and the help files without success.Thanks for any help that can be tossed my way.Regards,MikeIs it associated with a hotkey? Might be as easy as ControlSend() the hotkey to the Excel window. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Share this post Link to post Share on other sites
mikep56 0 Posted October 19, 2007 Hi PsaltyDS, The macro is launched by pressing a smiley face button that I placed on the toolbar that is associated with the macro. However, being in VB or VBS or VBA (I can't remember which), shouldn't the macro be launchable from an AutoIt script command. Right now I am using the mouse commands to click on the smiley face. Thanks for your help. regards, Mike Share this post Link to post Share on other sites
ptrex 162 Posted October 19, 2007 (edited) @allMaybe this can help you out.switches for ExcelYou can use a command line switch /m to activate a makro.Option 2 is this : Run Excel Macros through Automationregardsptrex Edited October 19, 2007 by ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Share this post Link to post Share on other sites
PsaltyDS 41 Posted October 19, 2007 @allMaybe this can help you out.switches for ExcelYou can use a command line switch /m to activate a makro.Option 2 is this : Run Excel Macros through AutomationregardsptrexThe references on Option 2 imply that you can only do four specific built-in macros that way: xlAutoActivate, xlAutoClose, xlAutoDeactivate, and xlAutoOpen. Does that work with ad hoc macros of your own? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Share this post Link to post Share on other sites
mikep56 0 Posted October 19, 2007 Hi All, After some deep internet searching, I found this simple way. Open the PERSONAL.XLS file in Excel. Right click the sheet1 tab at the bottom and select View Code. In the Project box on the left, click on ThisWorkbook. Then at the top left pulldown select Workbook, and type in Run "name of macro" between Private Sub Workbook_Open() and End Sub. Make sure that the macro name is in quotes. Then click on File, Save Personal.XLS. The next time you open Excel, the macro will run. Good luck and thanks again to all in this forum who helped. Regards, Mike Share this post Link to post Share on other sites
ptrex 162 Posted October 20, 2007 @PsaltyDS Yes works fine for any macro. ; AutoRun Macro Dim $objXL $objXL = ObjCreate("Excel.Application") With $objXL.Application .Visible = True ;Open the Workbook .Workbooks.Open ("C:\Test.xls") $x = .Run("Test") ; MacroName, Parameters1, Parameter2, ... EndWith Regards ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Share this post Link to post Share on other sites
PsaltyDS 41 Posted October 20, 2007 @PsaltyDS Yes works fine for any macro. ; AutoRun Macro Dim $objXL $objXL = ObjCreate("Excel.Application") With $objXL.Application .Visible = True ;Open the Workbook .Workbooks.Open ("C:\Test.xls") $x = .Run("Test") ; MacroName, Parameters1, Parameter2, ... EndWith Regards ptrex Coolness! Thanks for the tip. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Share this post Link to post Share on other sites
ptrex 162 Posted October 21, 2007 @PsaltyDS You're welcome !! See you around. regards, ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Share this post Link to post Share on other sites