View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
[email protected] duane.roelands@gmail.com is offline
external usenet poster
 
Posts: 1
Default Automating from javascript - can't get Excel window to front

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;
}