Mike32 Posted January 2, 2011 Share Posted January 2, 2011 I have the following problem. I want to list the macros of an Excel workbook in a listbox of Autoit. So the user may choose a macro for starting it. How is it possible? Thanks! Mike32 Link to comment Share on other sites More sharing options...
Juvigy Posted January 3, 2011 Share Posted January 3, 2011 This should get you started: $oExcel = ObjCreate("Excel.Application") $oExcel.Visible = 1 $oExcel.WorkBooks.Open("C:\2010.xls") $oModules = $oExcel.ActiveWorkbook.VBProject.VBComponents For $oModule in $oModules ConsoleWrite($oModule.Name&@CRLF) Next Link to comment Share on other sites More sharing options...
Mike32 Posted January 3, 2011 Author Share Posted January 3, 2011 @ Juvigy Thx for your answer. I have tested the code. On line 4 ($oModules = $oExcel.ActiveWorkbook.VBProject.VBComponents) there will be an error. Auoit doesn't work and will stop there. Does your code work with your 2010.xls? In my workbook there is the modul "Modul1" with 6 macros. Thx Greetings Mike32 Link to comment Share on other sites More sharing options...
Juvigy Posted January 3, 2011 Share Posted January 3, 2011 What error do you get? It works for me on a Excel 2007 and WinXP. Maybe try to decrease the security settings? Link to comment Share on other sites More sharing options...
Mike32 Posted January 5, 2011 Author Share Posted January 5, 2011 @Juvigy You are right. It was my mistake. The VBProject has a password. Is it possible to unlock the VBproject and to lock it later with Autoit3 when you know the password? Thx Greetings Mike32 Link to comment Share on other sites More sharing options...
Juvigy Posted January 6, 2011 Share Posted January 6, 2011 Not sure. Most likely No. Try those : ActiveWorkbook.VBProject.Protection ;Read only property ActiveWorkbook.Unprotect (Password) ;most likely just for excel wb not VB. Link to comment Share on other sites More sharing options...
Mike32 Posted January 6, 2011 Author Share Posted January 6, 2011 @Juvigy Thanks!! The first command works. The second not. Greetings Mike32 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