/// <summary> /// Call this to get the running Excel application, returns null if there isn't any. /// </summary> /// <returns>IExcelApplication or null</returns> private static IExcelApplication GetExcelApplication() { IExcelApplication excelApplication = COMWrapper.GetInstance <IExcelApplication>(); InitializeVariables(excelApplication); return(excelApplication); }
/// <summary> /// Call this to get the running powerpoint application, returns null if there isn't any. /// </summary> /// <returns>IPowerpointApplication or null</returns> private static IPowerpointApplication GetPowerpointApplication() { IPowerpointApplication powerpointApplication = COMWrapper.GetInstance <IPowerpointApplication>(); InitializeVariables(powerpointApplication); return(powerpointApplication); }
/// <summary> /// Get the captions of all the open word documents /// </summary> /// <returns></returns> public static List <string> GetWordDocuments() { List <string> documents = new List <string>(); try { using (IWordApplication wordApplication = COMWrapper.GetInstance <IWordApplication>()) { if (wordApplication != null) { if (version == null) { version = wordApplication.Version; } for (int i = 1; i <= wordApplication.Documents.Count; i++) { IWordDocument document = wordApplication.Documents.item(i); if (document.ReadOnly) { continue; } if (isAfter2003()) { if (document.Final) { continue; } } documents.Add(document.ActiveWindow.Caption); } } } } catch (Exception ex) { LOG.Warn("Problem retrieving word destinations, ignoring: ", ex); } return(documents); }
/// <summary> /// Call this to get the running outlook application, returns null if there isn't any. /// </summary> /// <returns>IOutlookApplication or null</returns> private static IOutlookApplication GetOutlookApplication() { IOutlookApplication outlookApplication = COMWrapper.GetInstance <IOutlookApplication>(); InitializeVariables(outlookApplication); return(outlookApplication); }
public static void Info() { try { using (IRemedyUserApplication remedyApplication = COMWrapper.GetInstance <IRemedyUserApplication>()) { if (remedyApplication != null) { //COMWrapper.DumpTypeInfo(remedyApplication); ICOMFormWnd2 form = remedyApplication.GetActiveForm(); //COMWrapper.DumpTypeInfo(form); LOG.InfoFormat("Server name {0}", form.GetServerName()); LOG.InfoFormat("Form name {0}", form.GetFormName()); if (HELP_DESK.Equals(form.GetFormName())) { ICOMField4 field = form.GetFieldById(FIELD_INCIDENT); //COMWrapper.DumpTypeInfo(field); LOG.InfoFormat("Incident {0}", field.Value); ICOMField4 fieldAttach = form.GetFieldById(FIELD_ATTACH); LOG.InfoFormat("Attachment {0}", fieldAttach.Value); } } } } catch (Exception ex) { LOG.Error(ex); } }
/// <summary> /// Call this to get the running outlook application, returns null if there isn't any. /// </summary> /// <returns>IWordApplication or null</returns> private static IWordApplication GetWordApplication() { IWordApplication wordApplication = COMWrapper.GetInstance <IWordApplication>(); InitializeVariables(wordApplication); return(wordApplication); }
/// <summary> /// Get the captions of all the open powerpoint presentations /// </summary> /// <returns></returns> public static System.Collections.Generic.List <string> GetPowerpointPresentations() { System.Collections.Generic.List <string> presentations = new System.Collections.Generic.List <string>(); try { using (IPowerpointApplication powerpointApplication = COMWrapper.GetInstance <IPowerpointApplication>()) { if (powerpointApplication != null) { if (version == null) { version = powerpointApplication.Version; } LOG.DebugFormat("Open Presentations: {0}", powerpointApplication.Presentations.Count); for (int i = 1; i <= powerpointApplication.Presentations.Count; i++) { IPresentation presentation = powerpointApplication.Presentations.item(i); if (presentation != null && presentation.ReadOnly != MsoTriState.msoTrue) { if (isAfter2003()) { if (presentation.Final) { continue; } } presentations.Add(presentation.Name); } } } } } catch (Exception ex) { LOG.Warn("Problem retrieving word destinations, ignoring: ", ex); } return(presentations); }
/// <summary> /// Insert image from supplied tmp file into the give excel workbook /// </summary> /// <param name="workbookName"></param> /// <param name="tmpFile"></param> public static void InsertIntoExistingWorkbook(string workbookName, string tmpFile) { using (IExcelApplication excelApplication = COMWrapper.GetInstance <IExcelApplication>()) { if (excelApplication != null) { for (int i = 1; i <= excelApplication.Workbooks.Count; i++) { IWorkbook workbook = excelApplication.Workbooks[i]; if (workbook != null && workbook.Name.StartsWith(workbookName)) { InsertIntoExistingWorkbook(workbook, tmpFile); } } } } }
/// <summary> /// Insert the bitmap stored under the tempfile path into the word document with the supplied caption /// </summary> /// <param name="wordCaption"></param> /// <param name="tmpFile"></param> /// <returns></returns> public static bool InsertIntoExistingDocument(string wordCaption, string tmpFile) { using (IWordApplication wordApplication = COMWrapper.GetInstance <IWordApplication>()) { if (wordApplication != null) { for (int i = 1; i <= wordApplication.Documents.Count; i++) { IWordDocument wordDocument = wordApplication.Documents.item(i); if (wordDocument.ActiveWindow.Caption.StartsWith(wordCaption)) { return(InsertIntoExistingDocument(wordDocument, tmpFile)); } } } } return(false); }
public static List <string> GetWorkbooks() { List <string> currentWorkbooks = new List <string>(); using (IExcelApplication excelApplication = COMWrapper.GetInstance <IExcelApplication>()) { if (excelApplication != null) { for (int i = 1; i <= excelApplication.Workbooks.Count; i++) { IWorkbook workbook = excelApplication.Workbooks[i]; if (workbook != null) { currentWorkbooks.Add(workbook.Name); } } } } return(currentWorkbooks); }
/// <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 = COMWrapper.GetInstance <IPowerpointApplication>()) { if (powerpointApplication != null) { LOG.DebugFormat("Open Presentations: {0}", powerpointApplication.Presentations.Count); for (int i = 1; i <= powerpointApplication.Presentations.Count; i++) { IPresentation presentation = powerpointApplication.Presentations.item(i); if (presentation != null && presentation.Name.StartsWith(presentationName)) { try { AddPictureToPresentation(presentation, tmpFile, imageSize, title); return(true); } catch (Exception e) { LOG.Error(e); } } } } } return(false); }