Задайте вопросЗадайте вопрос
 

ОтвеченоConvert HTML to Word Document

Ответы

  • 23 сентября 2008 г. 0:22Yuen Li Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     ОтвеченоС кодом
     Hi! I did found a solution from somewhere else. You can try to open HTML file in word using Microsoft.Office.Interop.Word and save it in *.doc file type. Here are the sample codes that I used:-

    object filename1 = filename;
    object oMissing = System.Reflection.Missing.Value;
    object readOnly = false;
    object oFalse = false;

    Microsoft.Office.Interop.Word.Application oWord = new Microsoft.Office.Interop.Word.Application();
    Microsoft.Office.Interop.Word.
    Document oDoc = new Microsoft.Office.Interop.Word.Document();
    oDoc = oWord.Documents.Add(
    ref oMissing, ref oMissing, ref oMissing, ref oMissing);
    oWord.Visible =
    false;

    oDoc = oWord.Documents.Open(ref filename1, ref oMissing, ref readOnly, ref oMissing, ref oMissing, ref oMissing,ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,ref oMissing, ref oMissing);

    filename1 = @"D:\FileConverter\Temp\new.doc";
    object fileFormat = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatDocument;
    oDoc.SaveAs(
    ref filename1, ref fileFormat, ref oMissing, ref oMissing,ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,ref oMissing, ref oMissing, ref oMissing);

    oDoc.Close(ref oFalse, ref oMissing, ref oMissing);
    oWord.Quit(
    ref oMissing, ref oMissing, ref oMissing);

    Regards,
    Yuen Li

    • Помечено в качестве ответаYuen Li 23 сентября 2008 г. 0:22
    •  

Все ответы

  • 22 сентября 2008 г. 22:33cs0kalom Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     
    Hi,  I am new here to this website.   There is a lot of great information on here.  

    I was wondering if you ever found a way to do this, perhaps through another avenue.  I am curious about doing this myself.

    Thank you for your help.

    Best wishes to you.

    Bea
  • 23 сентября 2008 г. 0:22Yuen Li Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     ОтвеченоС кодом
     Hi! I did found a solution from somewhere else. You can try to open HTML file in word using Microsoft.Office.Interop.Word and save it in *.doc file type. Here are the sample codes that I used:-

    object filename1 = filename;
    object oMissing = System.Reflection.Missing.Value;
    object readOnly = false;
    object oFalse = false;

    Microsoft.Office.Interop.Word.Application oWord = new Microsoft.Office.Interop.Word.Application();
    Microsoft.Office.Interop.Word.
    Document oDoc = new Microsoft.Office.Interop.Word.Document();
    oDoc = oWord.Documents.Add(
    ref oMissing, ref oMissing, ref oMissing, ref oMissing);
    oWord.Visible =
    false;

    oDoc = oWord.Documents.Open(ref filename1, ref oMissing, ref readOnly, ref oMissing, ref oMissing, ref oMissing,ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,ref oMissing, ref oMissing);

    filename1 = @"D:\FileConverter\Temp\new.doc";
    object fileFormat = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatDocument;
    oDoc.SaveAs(
    ref filename1, ref fileFormat, ref oMissing, ref oMissing,ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,ref oMissing, ref oMissing, ref oMissing);

    oDoc.Close(ref oFalse, ref oMissing, ref oMissing);
    oWord.Quit(
    ref oMissing, ref oMissing, ref oMissing);

    Regards,
    Yuen Li

    • Помечено в качестве ответаYuen Li 23 сентября 2008 г. 0:22
    •  
  • 26 сентября 2008 г. 2:25cs0kalom Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     
    Yikes!! This looks scarey.  i'll have to try it.

    Thanks! 

    Bea
    Thanks! Bea
  • 26 мая 2009 г. 7:10Kaushal.NET Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     
    Hello,

           I have done that much task as well as applying some of the formatting to document object also as like to create header,footer,border,

    document created successfully,but now my problem is my content is in html format now i want to display that content as a html formatted

    on my created word document,for that i have use

    object fileFormat = Microsoft.Office.Interop.Word. WdSaveFormat .wdFormatFilteredHTML;

    then i can get proper document,but at that time document cound't affect with applied formatting means it doesn't disply header

    and footer, while i have change above syntax as like below

    object fileFormat = Microsoft.Office.Interop.Word. WdSaveFormat .wdFormatDocument;

    then header and footer wil display but agin i m not getting html formated text on word document.

    now my problem is vise versa if i want to solve one problem then its create second one ....please help me to short out problem

    Thanks,

    Kaushal Pathak.