Thursday, March 19, 2009

How to call excel macro from java

since excel macro is vb code, since we can make a vb script file called from java and it calls excel macro

make a script file as content is

Dim objXL
Set objXL = CreateObject("Excel.Application")
With objXL
.Workbooks.Open ("File_Path")
.Application.Run "Macro_Name"
End With
Set objXL = Nothing

and save it as calling.vbs

in java you can call it as Runtime.getRuntime().exec("cmd /c start calling.vbs"); with in try,catch

Author : Anuj Patel
LinkedIn :
Blog :

No comments:

Post a Comment