PC Review


Reply
Thread Tools Rate Thread

C#.NET convert html to word avoid warnings by word object

 
 
rhitam
Guest
Posts: n/a
 
      29th Apr 2009
Hi all ,

I am trying to open an strict xhtml document by using word object and
trying to save as a word document. Below is my code :



public static void CreateWord(String HtmlFile)

{



object filename1 = HtmlFile;

object oMissing = System.Reflection.Missing.Value;


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 = @"C:\Testproject\Testproject\bin\Debug
\Report.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);



}

while executing above code , i get a warning like this :

"Linked style sheets are supported only in web format files. By
saving to this format , all links to style sheets would be lost"

How can i avoid such warnings through the program ? Also after i click
"continue" , a blank word document opens , even though i have
oWord.Visible =

false;

in my code

Any ideas ?

 
Reply With Quote
 
 
 
 
Tim Williams
Guest
Posts: n/a
 
      30th Apr 2009
In VBA-worl this kind of thing can often be avoided by setting

Application.DisplayAlerts = False

So you could try the C# equivalent.

Tim

"rhitam" <(E-Mail Removed)> wrote in message
news:ac60c401-3fc5-4258-bcf6-(E-Mail Removed)...
> Hi all ,
>
> I am trying to open an strict xhtml document by using word object and
> trying to save as a word document. Below is my code :
>
>
>
> public static void CreateWord(String HtmlFile)
>
> {
>
>
>
> object filename1 = HtmlFile;
>
> object oMissing = System.Reflection.Missing.Value;
>
>
> 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 = @"C:\Testproject\Testproject\bin\Debug
> \Report.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);
>
>
>
> }
>
> while executing above code , i get a warning like this :
>
> "Linked style sheets are supported only in web format files. By
> saving to this format , all links to style sheets would be lost"
>
> How can i avoid such warnings through the program ? Also after i click
> "continue" , a blank word document opens , even though i have
> oWord.Visible =
>
> false;
>
> in my code
>
> Any ideas ?
>



 
Reply With Quote
 
rhitam
Guest
Posts: n/a
 
      1st May 2009
Tim,



i tried something like this :

oWord.DisplayAlerts =
Microsoft.Office.Interop.Word.WdAlertLevel.wdAlertsNone;

But it is not working ... it still is giving the same warning
message.

What to do ?

-R








 
Reply With Quote
 
rhitam
Guest
Posts: n/a
 
      1st May 2009
On May 1, 4:04*pm, rhitam <rhitamsan...@gmail.com> wrote:
> Tim,
>
> i tried something *like this :
>
> oWord.DisplayAlerts =
> Microsoft.Office.Interop.Word.WdAlertLevel.wdAlertsNone;
>
> But it is not working ... it still is giving the same warning
> message.
>
> What to do ?
>
> -R


Hey , figured it out , used internal style instead So now no
such warnings, but while saving the the file , another dialog box
comes , saying "this file is in use by another aplication or user
(Normal.dot) . How to avoid something like that ?
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert Html to Word =?Utf-8?B?TWlrZSBDb2xsaW5z?= Microsoft ASP .NET 0 20th Sep 2006 04:34 PM
Convert Word to HTML in ASP.NET 1.1 =?Utf-8?B?VG9ueQ==?= Microsoft ASP .NET 1 16th Dec 2005 01:50 AM
Creating a Word document in .NET - convert HTML to Word? =?Utf-8?B?ZWR3YWxkbw==?= Microsoft Dot NET 0 12th May 2005 05:04 PM
how do i convert html to word =?Utf-8?B?d2Rz?= Microsoft Word Document Management 1 7th Dec 2004 04:17 PM
How to convert a Word .doc to .html (preferably with Word 2000) from .Net =?Utf-8?B?R3JhbnQgT3Jk?= Microsoft ASP .NET 0 14th Mar 2004 02:36 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:43 AM.