Open Excel Workbook & Cycle Sheets
i want open workbook , cycle through sheets in workbook. below trying, gives me error of object not set instance ofa n objet
excel.application oxl; excel._workbook owb; wb = oxl.workbooks.open("workbookname", missing.value, true); { //this line throws error on owb.worksheets foreach (excel.worksheet displayworksheet in owb.worksheets) { //more stuff here } }
you need set wb something. try putting code below directly above foreach line
owb = oxl.activeworkbook;
Visual Studio Languages , .NET Framework > Visual C#
Comments
Post a Comment