V
Virgul
Hi,
I try in my winform to open a word document print it and close.
But I have some problem when the document is to big word dont print it.
I think it's because I close it before that he have the time to complete
open it and launch the command to print.
I have put Thread.Sleep(5000); for wait a moment and that work!
But I dont to make wait my programm if they dont need to wait and if I have
a larger document that will not work so my question is what I need to make
for that my word document is print before close it?
My Code:
Word.Application newApp = new Word.Application();
Word.Document newdoc;
private void printWord(string ctp, string Temp)
{
newApp = new Word.Application();
string filePath = temp + "\\form" + cpt + ".pnet";
object o = System.Reflection.Missing.Value;
object True = true;
object Source = filePath;
newApp.Visible = false;
newdoc = newApp.Documents.Open(ref Source, ref o, ref o, ref o, ref o, ref
o, ref o, ref o, ref o, ref o, ref o, ref o, ref o, ref o, ref o, ref o);
newdoc.PrintOut(ref o, ref o, ref o, ref o, ref o, ref o, ref o, ref o, ref
o, ref o, ref o, ref o, ref o, ref o, ref o, ref o, ref o, ref o);
Thread.Sleep(5000);
if (SaveEhra == "1")
{
object Source2 = temp + "\\EHRA.xml";
newdoc.XMLSaveDataOnly = true;
newdoc.SaveAs(ref Source2, ref o, ref o, ref o, ref o, ref o, ref o,
ref o, ref o, ref o, ref o, ref o, ref o, ref o, ref o, ref o);
}
newdoc.Close(ref o, ref o, ref o);
object Savequit = false;
newApp.Quit(ref Savequit, ref o, ref o);
}
Have you any idea about what I'm doing wrong?
Thanks a lot for your help
++
Thierry
I try in my winform to open a word document print it and close.
But I have some problem when the document is to big word dont print it.
I think it's because I close it before that he have the time to complete
open it and launch the command to print.
I have put Thread.Sleep(5000); for wait a moment and that work!
But I dont to make wait my programm if they dont need to wait and if I have
a larger document that will not work so my question is what I need to make
for that my word document is print before close it?
My Code:
Word.Application newApp = new Word.Application();
Word.Document newdoc;
private void printWord(string ctp, string Temp)
{
newApp = new Word.Application();
string filePath = temp + "\\form" + cpt + ".pnet";
object o = System.Reflection.Missing.Value;
object True = true;
object Source = filePath;
newApp.Visible = false;
newdoc = newApp.Documents.Open(ref Source, ref o, ref o, ref o, ref o, ref
o, ref o, ref o, ref o, ref o, ref o, ref o, ref o, ref o, ref o, ref o);
newdoc.PrintOut(ref o, ref o, ref o, ref o, ref o, ref o, ref o, ref o, ref
o, ref o, ref o, ref o, ref o, ref o, ref o, ref o, ref o, ref o);
Thread.Sleep(5000);
if (SaveEhra == "1")
{
object Source2 = temp + "\\EHRA.xml";
newdoc.XMLSaveDataOnly = true;
newdoc.SaveAs(ref Source2, ref o, ref o, ref o, ref o, ref o, ref o,
ref o, ref o, ref o, ref o, ref o, ref o, ref o, ref o, ref o);
}
newdoc.Close(ref o, ref o, ref o);
object Savequit = false;
newApp.Quit(ref Savequit, ref o, ref o);
}
Have you any idea about what I'm doing wrong?
Thanks a lot for your help
++
Thierry