How to get the title of a presentation of a powerpoint app C#
Hello experts,
My idea is that when I create a presentation a button will be created automatically and when I close it, the button must be removed so I need to get the title of the presentation do you have any idea ?
Here is what I did:
using Powerpoint = Microsoft.Office.Interop.PowerPoint; Powerpoint.Application wdApp = new Powerpoint.Application(); string oldCaption = wdApp.Application.Caption ; string guid = Guid.NewGuid().ToString(); //set caption to random value wdApp.Application.Caption = guid; //create a presentation PresentationpptPresentation=wdApp.Presentations.Add(Microsoft.Office.Core.MsoTriState.msoTrue); //make sure app is visible: wdApp.Visible = true; //find random value to get process id //here I need to get the title of the presentation int processId = GetProcessIdByWindowTitle(guid); //reset caption wdApp.Application.Caption = oldCaption; //create a dictionary Dictionary<int, Button> mapping = new Dictionary<int, button>(); //add mapping mapping.Add(new KeyValuePair<int, Button>(processId, deleteButton)); //found this online: /// <summary> /// Returns the name of that process given by that title /// </summary> /// <param name="AppId">Int32MaxValue re public static int GetProcessIdByWindowTitle(string AppId) { Process[] P_CESSES = Process.GetProcesses(); for (int p_count = 0; p_count < P_CESSES.Length; p_count++) { if (P_CESSES[p_count].MainWindowTitle.Equals(AppId)) { return P_CESSES[p_count].Id; } } return Int32.MaxValue; }