Thank you, I've adopted the solution reported in the 2° link.
I have a problem with the step SaveAs.
If I specify wdFormatPDF as output format it gives me an error ("outsize value").
If I specify any other output format (ex. wdFormatHTML) it works.
I have installed Office 2003.
Any suggestions?
public Boolean Print_Interop(int FileTyp, string Doc_Name, string PDF_Name)
{
Word.ApplicationClass MSWordDoc;
object UnknownType = Type.Missing;
Boolean TOk = false;
object InputLocation = Doc_Name;
object OutputLocation = PDF_Name;
MSWordDoc = new Word.ApplicationClass();
try
{
MSWordDoc.Documents.Open(ref InputLocation,
ref UnknownType,
ref UnknownType,
ref UnknownType,
ref UnknownType,
ref UnknownType,
ref UnknownType,
ref UnknownType,
ref UnknownType,
ref UnknownType,
ref UnknownType,
ref UnknownType,
ref UnknownType,
ref UnknownType,
ref UnknownType,
ref UnknownType);
object SavePDFFormat = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatPDF;
MSWordDoc.ActiveDocument.SaveAs(ref OutputLocation,
ref SavePDFFormat,
ref UnknownType,
ref UnknownType,
ref UnknownType,
ref UnknownType,
ref UnknownType,
ref UnknownType,
ref UnknownType,
ref UnknownType,
ref UnknownType,
ref UnknownType,
ref UnknownType,
ref UnknownType,
ref UnknownType,
ref UnknownType);
MSWordDoc.Documents.Close(ref UnknownType, ref UnknownType, ref UnknownType);
MSWordDoc.Quit(ref UnknownType, ref UnknownType, ref UnknownType);
TOk = true;
}
catch (Exception e)
{
Console.WriteLine("{0} Exception caught.", e);
TOk = false;
}
return TOk;
}