Jump to content

Run Excel Macro


Recommended Posts

What i would like to do is:

1) Open an excel file // no problem, this is very simple

2) wait for excel file completely load // i can use sleep function and use a very long time to be sure

3) run an excel macro called "mymacro1" // i don't know how to do this

Can you give me the correct sintax for point three?

thank you

Link to comment
Share on other sites

Thank you very much.

I have another question, don't know if it is possible.

Before run excel file i want (with _ExcelBookOpen($file, 1)) i want to check if, accidentally, there are other excel files already open. In that case i want close all of them (saving before exit).

Is possible to do this check and close all other excel files eventually opened?

Thanks

Link to comment
Share on other sites

Found the solution.

Paste here for other interested users of this beautiful forum:

$oExcel = ObjGet("", "Excel.Application")

For $element In $oExcel.Application.Workbooks

If $element.FullName <> "" Then

MsgBox(0,"",$element.FullName)

$element.Save

$element.Close

Else

$element.Activate

$oExcel.Application.Dialogs(5).Show

EndIf

Next

$oExcel.Application.Quit

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...