Sign in to follow this  
Followers 0
Mike32

List of Excel macros

7 posts in this topic

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

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
Share on other sites

@ 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

Share this post


Link to post
Share on other sites

What error do you get? It works for me on a Excel 2007 and WinXP.

Maybe try to decrease the security settings?

Share this post


Link to post
Share on other sites

@Juvigy

You are right. It was my mistake. :x

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

Share this post


Link to post
Share on other sites

Not sure. Most likely No. Try those :

ActiveWorkbook.VBProject.Protection ;Read only property

ActiveWorkbook.Unprotect (Password) ;most likely just for excel wb not VB.

Share this post


Link to post
Share on other sites

@Juvigy

Thanks!!

The first command works. The second not.

Greetings

Mike32

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0