Javascript. Is there a way to export HTML along with formatting to a text document using ActiveX?

I figured out a way to write a word using an ActiveX component, but I'm not sure if it can be written HTML in Word.

function generateWord(elementIdValue){

  var value=$("#"+elementIdValue)).html();

  var word= new ActiveXObject('Word.Application');
  word.Visible=true;
  var doc=word.Documents.Add();
  var sel=word.Selection;
  sel.TypeText(value);

}

      

I don't want to save HTML directly to the word (it is not readable with all html tags), rather I want to write the data along with the HTML styling in the word.

I have successfully written HTML for Outlook along with formatting using HTMLBody property,

var objO = new ActiveXObject('Outlook.Application');     
var objNS = objO.GetNameSpace('MAPI');     
var mItm = objO.CreateItem(0);     
mItm.To = "";
mItm.Subject = "Test";
mItm.HTMLBody = (($(("#"+elementIdValue)).html())

      

Is there a property on a word object similar to an Outlook object that can consume HTML?

+3


source to share


1 answer


You can achieve this without using ActiveX. Check it out .



0


source







All Articles