Click here to Skip to main content
15,901,283 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey

I can access Excel sheet using JavaScript code but I want to call or run Macro in that excel sheet...

Can anyone help me to fix it.

Thanks in advance.
Waiting for reply.
Posted
Updated 9-Mar-11 21:15pm
v2

This is an Excel Macro question, not a java question.

In the sheet you want opened, go to the VBE.
Open 'ThisWorkbook'

Once here, you can select "Workbook" from the Object drop down list, located in the top left of the module pane.

Type Private Sub Workbook_Open() and put in the macro call.

Example:
VB
Private Sub Workbook_Open()
Run "Macro1"
End Sub



Then whenever the workbook is opened, the macro will run, regardless of whether it is called by yourself from Excel, by another Excel sheet, or by java etc.


I hope this helps, please vote up if it does!
 
Share this answer
 
Comments
Albin Abel 11-Mar-11 7:16am    
My 5
Farah Siraj 13-Mar-11 11:51am    
Thanx for your help but the problem is that what will happen if anyone wants to open the same excel file and wants some modification without running macro automatically so due to this automatic setting atleast one time macro will run and its not desirable...
Can anyone tell me the solution...
Thanks in advance.
this[^] might help you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900