/// <summary> /// Export the image from the tmpfile to the presentation with the supplied name /// </summary> /// <param name="presentationName">Name of the presentation to insert to</param> /// <param name="tmpFile">Filename of the image file to insert</param> /// <param name="imageSize">Size of the image</param> /// <param name="title">A string with the image title</param> /// <returns></returns> public static bool ExportToPresentation(string presentationName, string tmpFile, Size imageSize, string title) { using (IPowerpointApplication powerpointApplication = GetPowerpointApplication()) { if (powerpointApplication == null) { return(false); } using (IPresentations presentations = powerpointApplication.Presentations) { LOG.DebugFormat("Open Presentations: {0}", presentations.Count); for (int i = 1; i <= presentations.Count; i++) { using (IPresentation presentation = presentations.item(i)) { if (presentation == null) { continue; } if (!presentation.Name.StartsWith(presentationName)) { continue; } try { AddPictureToPresentation(presentation, tmpFile, imageSize, title); return(true); } catch (Exception e) { LOG.Error(e); } } } } } return(false); }
/// <summary> /// Get the captions of all the open powerpoint presentations /// </summary> /// <returns></returns> public static List <string> GetPowerpointPresentations() { List <string> foundPresentations = new List <string>(); try { using (IPowerpointApplication powerpointApplication = GetPowerpointApplication()) { if (powerpointApplication == null) { return(foundPresentations); } using (IPresentations presentations = powerpointApplication.Presentations) { LOG.DebugFormat("Open Presentations: {0}", presentations.Count); for (int i = 1; i <= presentations.Count; i++) { using (IPresentation presentation = presentations.item(i)) { if (presentation == null) { continue; } if (presentation.ReadOnly == MsoTriState.msoTrue) { continue; } if (IsAfter2003()) { if (presentation.Final) { continue; } } foundPresentations.Add(presentation.Name); } } } } } catch (Exception ex) { LOG.Warn("Problem retrieving word destinations, ignoring: ", ex); } foundPresentations.Sort(); return(foundPresentations); }