eg a user selects multiple worksheets in a workbook using CTRL+Click. How can I determine which worksheets are selected and which not? I was playing around with that but I couldn't find any useful property to check.
Excel.Sheets abc = Globals.ThisAddIn.Application.ActiveWorkbook.Worksheets;
foreach (Excel.Worksheet sheet in abc)
{
if (sheet.EnableSelection != Excel.XlEnableSelection.xlNoSelection)
{
}
}
I was struggeling around for almost 2 hours. But shortly after I posted this question I found a solution. The ActiveWindow.SelectedSheets delivers what I was looking for.
Excel.Sheets abc = Globals.ThisAddIn.Application.ActiveWindow.SelectedSheets;
foreach (Excel.Worksheet sheet in abc)
{
string asdf = sheet.Name;
}
I haven't knwon the ActiveWindow before. Still hoping this is useful for someone else, too.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.