title: C++ Excel saving workbook
body: <p>I'm creating an Excel chart using C++. Im having problem with saving workbook with few sheets. Here is my code:</p>
  
  <pre><code>try
  {
  
      CoInitialize(NULL);
      Excel::_ApplicationPtr XL;
      XL.CreateInstance(L"Excel.Application");
      XL-&gt;Visible=false;
      Excel::_WorkbookPtr workbook = XL-&gt;Workbooks-&gt;Add(Excel::xlWorksheet);
      Excel::_WorksheetPtr pSheet= XL-&gt;ActiveSheet;
  
  
      for (i='1';i&lt;='z';i++){
  
  
                  pSheet = XL-&gt;Worksheets-&gt;Add();
  
                  char arr[25];
  
  
                      sprintf(arr, "Podaci za %c", i);
  
                  pSheet-&gt;Name = arr;
  
                          ...
  
  
  
      }
  
  
  pSheet = XL-&gt;Worksheets-&gt;Add();
  pSheet-&gt;Name = "some page";
  
  pSheet-&gt;SaveAs("c:\\test.xls");
  
  
  
  workbook-&gt;Close();
  XL-&gt;Quit();
  
  
  }
  
  catch(_com_error &amp; error)
  {
      printf("\n  Greska u komunikaciji s MS Excelom.");
  }
  
  CoUninitialize();
  </code></pre>
  
  <p>I have a for loop that creates few sheets. "..." represents the part of code where i fill tables. It all worked great until i tried saving it. Now when it cones to SaveAs() jumps to catch. I also tried using workbook->saveas("table.xls"); but I dont know the right syntax.</p>
  
  <p>Thanks for help in advance!</p>