Is there a way to change the following VBScript in javascript?
I'm trying to convert some VBScript to javascript, but I doubt it's possible because it seems to be specific to MS apps and code. I would like to help with one of two possible outcomes: a) actually convert the code to javascript, or b) demonstrate that converting it to javascript is currently not possible.
The specific VBScript statements that I find too specific to MS are as follows:
set oExcel = CreateObject("Excel.Application")
set oBook = oExcel.Workbooks.Add
oBook.HTMLProject.HTMLProjectItems("Sheet1").Text = sHTML
oBook.HTMLProject.RefreshDocument()
oExcel.Visible = True
oExcel.UserControl = True
Has anyone referenced javascript and Excel well enough for a solution to exist?
+1
a source to share
2 answers
I am sure that: -
var excel = new ActiveXObject("Excel.Application")
var book = excel.Workbooks.Add()
//The line below doesn't work in Excel 2007
// book.HTMLProject.HTMLProjectItems["Sheet1"].Text = sHtml
var sheet = book.Sheets("Sheet1")
sheet.Range("A2").Value = "Hello World"
excel.Visible = true
excel.UserControl = true
+3
a source to share
You can only do this with JScript, not JavaScript - this will show you how . This might be fine if you only use IE.
+1
a source to share