2009-10-26 112 views
1

我試圖通過我在C#中的Windows應用程序打印PowerPoint文檔。我正在使用Microsoft.Office.Interop.PowerPoint來實現此功能。以下是我用過的代碼。它將請求發送給打印機,但沒有打印。PowerPoint打印C# - 沒有打印

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();` 

回答

0

調試時,嘗試work.PrintOut後停止,並檢查您的打印機,看看作業到達。我猜你正在關閉PowerPoint太快。