public static Session Session(this xlApp app) { Requires.NotNull(app, nameof(app)); using (var process = app.AsProcess()) { return(new Session(process.SessionId)); } }
public static void Activate(this xlApp app) { Requires.NotNull(app, nameof(app)); using (var process = app.AsProcess()) { NativeMethods.BringToFront(process); } }
public void ExcelAppConverter_CanGetProcessFromApp() { var app = new xlApp(); try { var process = app.AsProcess(); Assert.NotNull(process); } finally { app.Quit(); } }
public static bool IsVisible(this xlApp app) { Requires.NotNull(app, nameof(app)); try { using (var process = app.AsProcess()) { return(app.Visible && process.IsVisible()); } } catch (COMException x) when(x.Message.StartsWith("The message filter indicated that the application is busy.") || x.Message.StartsWith("Call was rejected by callee.")) { //This means the application is in a state that does not permit COM automation. //Often, this is due to a dialog window or right-click context menu being open. return(false); } }