PowerPoint Printing C# - 什么都没打印

时间:2009-10-26 10:12:40

标签: c# interop printing powerpoint

我正在尝试通过C#中的Windows应用程序打印PowerPoint文档。我正在使用Microsoft.Office.Interop.PowerPoint来实现此功能。以下是我使用过的代码。它将请求发送给打印机,但没有任何内容被打印出来。

string filename = "C:\\test.ppt";
int copies = 1;

Microsoft.Office.Interop.PowerPoint.Presentation work = null;
Microsoft.Office.Interop.PowerPoint.Application app = new Microsoft.Office.Interop.PowerPoint.ApplicationClass();
Microsoft.Office.Interop.PowerPoint.Presentations presprint = app.Presentations;

work = presprint.Open(filename, Microsoft.Office.Core.MsoTriState.msoCTrue, Microsoft.Office.Core.MsoTriState.msoCTrue, Microsoft.Office.Core.MsoTriState.msoFalse);
//app.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;
work.PrintOptions.PrintInBackground = Microsoft.Office.Core.MsoTriState.msoFalse;
//work.PrintOptions.PrintInBackground = Microsoft.Office.Core.MsoTriState.msoTrue;
//work.PrintOptions.ActivePrinter = "HP LaserJet 5000 Series PCL6";
work.PrintOptions.ActivePrinter = app.ActivePrinter;    
work.PrintOut(1, work.Slides.Count, app.ActivePrinter, copies, Microsoft.Office.Core.MsoTriState.msoFalse);

work.Close();
app.Quit();`

1 个答案:

答案 0 :(得分:0)

调试时,请尝试在work.PrintOut后停止并检查打印机以查看作业是否到达。我猜你正在快速关闭PowerPoint。