Home Page
Articoli
Tips & Tricks
News
Forum
Archivio Forum
Blogs
Sondaggi
Rss
Video
Utenti
Chi Siamo
Contattaci
Username:
Password:
Login
Registrati ora!
Recupera Password
Home Page
Stanze Forum
ASP.NET 2.0 / 3.5 / 4.0
Stampare documento Word in C#
giovedì 21 febbraio 2008 - 10.53
Elenco Threads
Stanze Forum
Aggiungi ai Preferiti
Cerca nel forum
dipy
Profilo
| Junior Member
58
messaggi | Data Invio:
gio 21 feb 2008 - 10:53
Salve a tutti!
come posso fare per stampare un file word da C#?
Ferux
Profilo
| Newbie
44
messaggi | Data Invio:
gio 21 feb 2008 - 11:12
Salve,
prova con gli interop:
//References
using word = Microsoft.Office.Interop.Word;
//Paste this code in your function
word.ApplicationClass ac = new word.ApplicationClass();
word.Application app = ac.Application;;
object missingValue = Type.Missing;
object myTrue = true;
object myFalse = false;
try
{
app.DisplayAlerts = word.WdAlertLevel.wdAlertsNone;
object filename = thePathFileToPrint;
// Using OpenOld so as to be compatible with other versions of Word
ord.Document document = app.Documents.OpenOld(ref filename,
ref missingValue, ref missingValue,
ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue);
app.ActivePrinter = thePrinterName;
// Using PrintOutOld to be version independant
app.ActiveDocument.PrintOutOld(ref myTrue, ref myFalse, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref myFalse, ref missingValue, ref missingValue, ref missingValue);
document.Close(ref missingValue, ref missingValue, ref missingValue);
while(app.BackgroundPrintingStatus > 0)
{
System.Threading.Thread.Sleep(250);
}
app.Quit(ref missingValue, ref missingValue, ref missingValue);
}
catch(Exception exc)
{
app.Documents.Close(ref myFalse,ref myFalse,ref myFalse);
app.Quit(ref missingValue, ref missingValue, ref missingValue);
}
Spero ti aiuti
Saluti
Ing Ferux
[MCP MCAD]
Torna su
Stanze Forum
Elenco Threads
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?
Dopo esserti registrato potrai chiedere
aiuto sul nostro
Forum
oppure aiutare gli altri
Consulta le
Stanze
disponibili.
Registrati ora !