Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Create executable file to run excel macro

2,793 views
Skip to first unread message

Pawan

unread,
Aug 30, 2009, 7:54:01 AM8/30/09
to
Hi

I have written a complex macro in excel and now have to distribute it to
co-workers. However, I want to create an executable file which will run the
macro directly (will open the userform in my macro).

Is there any chance of doing so?

Thanks in advance

Regards,
Pawan

Joel

unread,
Aug 30, 2009, 9:56:01 AM8/30/09
to
Make the macro an Workbook open macro or call your macro from a workbook open.

Next create a BAT file to open the workbook and run the Bat.

Here is a sample of the bat file

"C:\Program Files\Microsoft Office\Office10\excel.exe" c:\temp\book1.xls

Pawan

unread,
Aug 30, 2009, 12:10:01 PM8/30/09
to
Thanks Joel

But I did not get the example given by you. It is exe file and it opens new
workbook. How can I use this to open the workbook that I wish?

Regards,
prm

Joel

unread,
Aug 30, 2009, 1:02:01 PM8/30/09
to
Book1.xls is the workbook that contains that macro you want to run. The Exe
file is Excel.exe (this is the file that starts excel). The command line I
gave your startup excel and opens the workbook book1.xls. You can change the
workbook name to any xls file you like.

Steve Yandl

unread,
Aug 30, 2009, 4:51:10 PM8/30/09
to
It would be possible to write an executable to launch your userform, even
easier to do so from a script file of some sort but I'm guessing that isn't
really what you want to do. Wouldn't it be simpler to just have the
userform come up when the workbook is first opened or to give your coworkers
a command button in the Workbook to launch the userform? Plus, using a
separate executable file means you not only have to distribute your workbook
but the exe file as well plus deal with any security concerns over exe files
that your employer might have.


Steve Yandl

"Pawan" <Pa...@discussions.microsoft.com> wrote in message
news:76B159FE-49F7-41F5...@microsoft.com...

Chip Pearson

unread,
Aug 30, 2009, 5:56:16 PM8/30/09
to
I would use a VBScript rather than an exe file. Open Notepad, and
enter the following in the text file:

Set XL=CreateObject("Excel.Application")
XL.Visible=True
XL.Workbooks.Open "C:\A.xls"
XL.Run "A.xls!TheMacro"


Change "C:\A.xls" to the appropriate file name. Change
"A.xls!!TheMacro" to the workbook name and macro name.

Save the file as a vbs file, e.g., RunIt.vbs rather than a txt file.

Then, all the user needs to do is double click the vbs file and Excel
will start, open C:\A.xls and execute TheMacro.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)

satinder....@gmail.com

unread,
Jul 10, 2019, 11:10:44 AM7/10/19
to
Thanks a lot Chip for this solution, however if i want to run a macro using using this and also want to pass parameters, how can i do that?
0 new messages