How to identify the current active worksheet is minimized ?
I do not want to run my operation when the current worksheet in excel is minimized. I am using excel interop and C#
You can do a conditional check on the following property,
If Application.WindowState = xlMinimized Then
// do something
End If
This is in VBA though.
Here is a basic code in C#
using Excel = Microsoft.Office.Interop.Excel;
Excel.Application myXL = new Excel.Application();
myXL.Visible = true;
//adding a new book
Excel.Workbook xlBookN = myXL.Workbooks.Add();
//opening exising book
String xlPath = "c:/myprojects/test.xls";
Excel.Workbook xlBookE = myXL.Workbooks.Open(xlPath,
0, false, 5, "", "", false, Excel.XlPlatform.xlWindows, "",
true, false, 0, true, false, false);
Dim myWindowState As XlWindowState //you could also use a variable
myXL.WindowState = myWindowState
//or you can check the state directly
If (myXL.WindowState = xlMinimized)
// do something
End If
Please check on the syntax and references.
You could get better reference from :
Tags: c#c#