none
Print Excel File In Selected Printer in Xp and Vista RRS feed

  • Question

  • I have written a sample application of print any file but it does not work for excel and .doc in selected printer on Xp and Vista.

    The following is a sample code:

    Process p = new Process();
             
    if (this.printDialog1.ShowDialog() == DialogResult.OK)
    {
         ProcessStartInfo info = new ProcessStartInfo();
         info.FileName = sFilePath;
         info.CreateNoWindow = true;
         info.UseShellExecute = true;

         //info.Arguments = this.printDialog1.PrinterSettings.PrinterName;
                       
         info.Arguments = "\"\\\\" + Dns.GetHostName() + "\\" + printDialog1.PrinterSettings.PrinterName + "\"";

         info.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
                          
         p.StartInfo = info;
         bool sdfvgfs=   p.Start();
         p.Close();
    }

    Please anybody know about solution?
    Thank You!

    Friday, March 25, 2011 11:06 AM

All replies