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

Example:
make a script file as content is

Dim objXL
Set objXL = CreateObject("Excel.Application")
With objXL
.Workbooks.Open ("File_Path")
.Application.Run "Macro_Name"
.Application.Quit
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

No comments:

Post a Comment