shikher.mishra
shikher.mishra

Reputation: 155

Creating macros for the excel sheet in VBscript or Javascript

I have been using VBscript for writing macros in the excel. But can I write javascript as well for writing the macros?

If yes , then which is much better and why?

Upvotes: 1

Views: 164

Answers (1)

Ansgar Wiechers
Ansgar Wiechers

Reputation: 200523

Excel macros can't be written in either VBScript or JavaScript. The language used in Microsoft Office macros is VBA (Visual Basic for Applications), which is similar to VBScript, but not identical.

What you can do with both VBScript and JavaScript is COM automation of Office applications (running from .vbs or .js files respectively):

var xl = new ActiveXObject("Excel.Application");
xl.Visible = true;

var wb = xl.Workbooks.Open("C:\\path\\to\\your.xlsx");
var ws = wb.Sheets(1);

ws.Cells(1,1).Value = "something";

wb.Save();
wb.Close();
xl.Quit();

However, you'll still be using VBA objects and methods that way.

Upvotes: 2

Related Questions