title: How to copy an Excel Worksheet from one Workbook to another
body: <p>I have been searching online for an answer to this. There are dozens of "solutions", but nothing seems to work right. The application I'm building (using C#) pulls data from a mdb querydef and creates an Excel workbook with two worksheets. That part works perfectly. Now for the part that should be simple: I have a workbook with multiple worksheets (each worksheet will calculate the data differently) I need the code to open the "template" workbook, copy the correct worksheet, and place the copy in the newly created workbook with the other two worksheets. Here's a sample of the code that I feel "should" work:</p>
  
  <pre><code>            _Application xlApp;
          Workbook xlTemplateWB;
          Workbook xlTempWB;
          object missing = System.Reflection.Missing.Value;
  
          xlApp = new ApplicationClass();
          xlApp.Visible = true;
  
          //Open Bench Sheet Template
          xlTemplateWB = xlApp.Workbooks.Open(Elmnt.getDBPath() + TEMPLATENAME, 0, true, 5, "", "",
              false, XlPlatform.xlWindows, "", true, false, 0, true, false, false);
  
          //Open temporary workbook
          xlTempWB = xlApp.Workbooks.Open(XLTempDir + XLTempName, 0, false, 5, true, "", true, 
              XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
  
          //Copy "BOD" Worksheet
          xlTempWB.Worksheets.Copy(xlTemplateWB.Worksheets["BOD"]);
          xlTempWB.Save();
  
          //Close Workbooks
          xlTempWB.Close(true, missing, missing);
          xlTemplateWB.Close(true, missing, missing);
          xlApp.Quit();
  
          //Release Objects
          releaseObject(xlTempWB);
          releaseObject(xlTemplateWB);
          releaseObject(xlApp);
  </code></pre>