[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How to run macro by using batch file?

Posted on 2016-11-03
8
Medium Priority
?
130 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 53

Accepted Solution

by:
Rgonzo1971 earned 2000 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 53

Assisted Solution

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

Author Comment

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

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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
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.

649 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