private void PublishWithPowerPoint(IDocumentPublisher4 publisher, string sourceFilename, string destinationFilename) { if (null == publisher) return; OfficeApplicationCache officeApplicationCache = OfficeApplicationCache.Instance; object presentation = officeApplicationCache.OpenDocument(sourceFilename, false, FileType.PowerPoint); try { publisher.PublishWithPowerPoint(destinationFilename, presentation); officeApplicationCache.CloseDocument(presentation, false); } finally { Marshal.ReleaseComObject(presentation); } }
private void PublishWithExcel(IDocumentPublisher4 publisher, string sourceFilename, string destinationFilename) { if (null == publisher) return; OfficeApplicationCache officeApplicationCache = OfficeApplicationCache.Instance; object workbook = officeApplicationCache.OpenDocument(sourceFilename, false, FileType.ExcelSheet); try { publisher.PublishWithExcel(destinationFilename, workbook); officeApplicationCache.CloseDocument(workbook, false); } finally { Marshal.ReleaseComObject(workbook); } }