Print Excel File In Selected Printer in Xp and Vista

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
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.
Here I am using .net 2.0 win form application on Vista 64-bit OS.
In my computer I am using open office not MS office.
The following is a sample code:
Process p = <span><span style="color:#0000ff new Process();<br/>
<br/>
<span><span style="color:#0000ff if (<span><span style="color:#0000ff this.printDialog1.ShowDialog() == DialogResult.OK)<br/>
{<br/>
ProcessStartInfo info = <span><span style="color:#0000ff new ProcessStartInfo();<br/>
info.FileName = sFilePath;<br/>
info.CreateNoWindow = <span><span style="color:#0000ff true;<br/>
info.UseShellExecute = <span><span style="color:#0000ff true;<br/>
<br/>
<span><span style="color:#008000 //<span><span style="color:#008000 info.Arguments = this.printDialog1.PrinterSettings.PrinterName;<br/>

<br/>
info.Arguments = <span style="color:#800080 <span>"<span>"\\" + Dns.GetHostName() + "\<span style="color:#800080 <span>"<span> + printDialog1.PrinterSettings.PrinterName + "<span style="color:#800080 <span>"<span>";<br/>
<br/>
info.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;<br/>

<br/>
p.StartInfo = info;<br/>
<span><span style="color:#0000ff bool sdfvgfs= p.Start();<br/>
p.Close();<br/>
}
Please anybody know about solution? <br/>
Thank You!
<
KK<br/>

View the full article
 
Back
Top