Automation from JavaScript

M

Mark Rae

Hi,

I need to write a JavaScript function which will accept a string of HTML and
then instantiate either Word or Excel and display that HTML. I have the
Excel stuff working, but am stuck on doing the same with Word. Below is the
JavaScript function so far.

function exportReport(pstrOutput, strHTML)
{
switch(pstrOutput)
{
case 'Excel' :
{
var objXL = new ActiveXObject("Excel.Application");
var objWB = objXL.Workbooks.Add;
objWB.HTMLProject.HTMLProjectItems('Sheet1').Text = strHTML;
objWB.HTMLProject.RefreshDocument;
objXL.Visible = true;
objXL = null;
}
case 'Word' :
{
var objWord = new ActiveXObject("Word.Application");
...
...
objWord.Visible = true;
objWord = null;
}
}
}

Can anyone please help me with the Word equivalent...?

Also, this always leaves an instance of EXCEL.exe running even if the user
closes Excel down manually - is there a way round this?

Any assistance gratefully received.

Mark
 

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