Solved

How to run macro by using batch file?

Posted on 2016-11-03
8
28 Views
Last Modified: 2016-12-01
Hi,

I have one excel. It contains macro.. i would like to run macro when the batch file clicked.. is there any way to run macro by using batch file??
0
Comment
Question by:venkatesh ks
8 Comments
 
LVL 49

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 41873476
HI,

pls try

'Your .bat
WScript "D:\YourFolder\yourfile.vbs"

Open in new window



'YourFile.vbs
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open("yourXLfile.xls")

'objExcel.Application.Visible = True

objExcel.Application.Run "Macro.TestMacro()"
objExcel.ActiveWorkbook.Close '(False)


objExcel.Application.Quit
WScript.Echo "Finished."
WScript.Quit

Open in new window

Regards
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 41873480
One way is to  configure excel to load the macro file as excel is opened. That macro file shall have to be placed in the XLSTART folder and  can contain an autorun macro. All the batch file will have to do is load excel and the macro can take care of the rest.
0
 

Author Comment

by:venkatesh ks
ID: 41873744
Hi Rgonzo1971,

I ran ur code,. But it show as run time error like  ," The macro may not be available in this workbook or all macros may be disabled.  Error code like "800A03EC"..."

I don't know how to solve it..

Advance thanks..
0
 
LVL 49

Assisted Solution

by:Rgonzo1971
Rgonzo1971 earned 500 total points
ID: 41873774
the user should hot have to click enable macros to be able to run it automatically
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:venkatesh ks
ID: 41873777
Hi Rgonzo1971,
 
I am not getting ur last answer.. please elaborate it..
0
 
LVL 49

Expert Comment

by:Rgonzo1971
ID: 41873844
When you open a xlsm file do you have to enable the macros?
0
 

Author Comment

by:venkatesh ks
ID: 41873895
I saved a macro as independent.. I would like to use that macro for every workbook,.. or what workbook i like..
0
 
LVL 14

Expert Comment

by:frankhelk
ID: 41908417
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I have recommended this question be closed as follows:

Split:
-- Rgonzo1971 (https:#a41873476)
-- Rgonzo1971 (https:#a41873774)


If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.

frankhelk
Experts-Exchange Cleanup Volunteer
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have published numerous articles here at Experts Exchange that present programs/scripts written in a language called AutoHotkey. Each of those articles has a brief paragraph describing where to download the product and how to install it. I have al…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now