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

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

How to Share webservice object to all user

How to fix error Msg 1801, Level 16, State 3, Line 1