title: C# set opened workbook
body: <p>I started creating an Excel-Add-IN with C#.</p>
  
  <p>what I need to do is simple, I need to set a workbook to a variable, the workbook is already running, I tried this but did not work</p>
  
  <pre><code>        Excel.Application excel = new Excel.Application();
          Excel.Workbook wb = excel.ActiveWorkbook as Excel.Workbook;
          wb.SaveAs("C:\\Users\\ro_sg\\Desktop\\Pasta1.xlsx");
          Excel.Worksheet ws = wb.Worksheets["Plan1"]; 
          Excel.Range range = ws.Range["A1"];
          range.Value = "Success";
  
          wb.Save();
  </code></pre>
  
  <p>The wb variable cannot find the workbook (gets null), and I can't see why.</p>
  
  <p>Please, if any of you spot the mistake let me know. </p>
  
  <p>Thanks!</p>