![]() |
Check if the first sheet is the selected sheet
Hello everyone,
I have a program that opens an excel template and then checks to see if the first sheet is selected, if it is then no error but i get an error irrespective of the fact whether the first is selected or not...i am pasting the code here and would appreciate it if someone can point what i am missing. TIA #region Excel Check 5: First sheet or multiple sheets selected if(OptionsData.XLCheckSelectedSheet)----(bool) { if(XLwb.Sheets.Count 1 && XLwb.ActiveSheet != XLwb.Sheets.get_Item(1)) { ErrorCounter++; ProcessError(ErrorCounter, "The first sheet is not the selected sheet"); } |
Check if the first sheet is the selected sheet
why dont you activate the first sheet after opening the file. This will
solve the problem of error because you then dont need to have this code in your workbook. melody wrote: Hello everyone, I have a program that opens an excel template and then checks to see if the first sheet is selected, if it is then no error but i get an error irrespective of the fact whether the first is selected or not...i am pasting the code here and would appreciate it if someone can point what i am missing. TIA #region Excel Check 5: First sheet or multiple sheets selected if(OptionsData.XLCheckSelectedSheet)----(bool) { if(XLwb.Sheets.Count 1 && XLwb.ActiveSheet != XLwb.Sheets.get_Item(1)) { ErrorCounter++; ProcessError(ErrorCounter, "The first sheet is not the selected sheet"); } |
Check if the first sheet is the selected sheet
thanks sonu,I cant do that because this a tool that is testing a
template to test certain test criteria... if i activate the first sheet then i will be doing it programatcally and that is not the intention... sonu wrote: why dont you activate the first sheet after opening the file. This will solve the problem of error because you then dont need to have this code in your workbook. melody wrote: Hello everyone, I have a program that opens an excel template and then checks to see if the first sheet is selected, if it is then no error but i get an error irrespective of the fact whether the first is selected or not...i am pasting the code here and would appreciate it if someone can point what i am missing. TIA #region Excel Check 5: First sheet or multiple sheets selected if(OptionsData.XLCheckSelectedSheet)----(bool) { if(XLwb.Sheets.Count 1 && XLwb.ActiveSheet != XLwb.Sheets.get_Item(1)) { ErrorCounter++; ProcessError(ErrorCounter, "The first sheet is not the selected sheet"); } |
Check if the first sheet is the selected sheet
Check if the activesheet index is 1.
-- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "melody" wrote in message ups.com... thanks sonu,I cant do that because this a tool that is testing a template to test certain test criteria... if i activate the first sheet then i will be doing it programatcally and that is not the intention... sonu wrote: why dont you activate the first sheet after opening the file. This will solve the problem of error because you then dont need to have this code in your workbook. melody wrote: Hello everyone, I have a program that opens an excel template and then checks to see if the first sheet is selected, if it is then no error but i get an error irrespective of the fact whether the first is selected or not...i am pasting the code here and would appreciate it if someone can point what i am missing. TIA #region Excel Check 5: First sheet or multiple sheets selected if(OptionsData.XLCheckSelectedSheet)----(bool) { if(XLwb.Sheets.Count 1 && XLwb.ActiveSheet != XLwb.Sheets.get_Item(1)) { ErrorCounter++; ProcessError(ErrorCounter, "The first sheet is not the selected sheet"); } |
All times are GMT +1. The time now is 05:59 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com