Automating from javascript - can't get Excel window to front

D

duane.roelands

I 've written some Javascript code to export a bunch of data to a an
Excel worksheet Everything works exactly as I would like, except that
the Excel window is not opening in front of the browser window; the
Excel window appears on the taskbar, blinking, and I need to click it
to bring it to the front. Here is my code; what am I missing?

function ExportExcel() {
// Open Excel and export the view data to it
var oXL = new ActiveXObject("Excel.Application");
oXL.Visible = true;

var oWB = oXL.Workbooks.Add();
var oSheet = oWB.ActiveSheet;

// Put the data on the sheet
var RangeStart = 'A2';
var RangeEnd = 'E500';
var RangeText = RangeStart + ':' + RangeEnd;
var oRange = oSheet.Range(RangeText)

// GetExcelArray() simply returns the data
oRange.Value = GetExcelArray();

oXL.Visible = true;
oXL.UserControl = true;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top