title: how to modify xlswritefig in MATLAB to use already existing file?
body: <p>There's a function written to add plots to Excel files:
  <a href="http://www.mathworks.com/matlabcentral/fileexchange/24424-xlswritefig" rel="nofollow">http://www.mathworks.com/matlabcentral/fileexchange/24424-xlswritefig</a>
  but it's old and doesn't work the way I need it to.</p>
  
  <p>How can I adapt this code to write to a file that already exists (is being created)? For example, if I have this line that works great:</p>
  
  <pre><code>xlswrite(filename, percentError, 1, 'C4');
  </code></pre>
  
  <p>and I want to put a figure next to the data, I'd like to write something like:</p>
  
  <pre><code>xlswritefig(gcf, filename, 'Sheet1', 'E2')
  </code></pre>
  
  <p>Which seems like it should work but I get a long error:</p>
  
  <p>Error using Interface.000208DB_0000_0000_C000_000000000046/invoke Invoke Error, Dispatch Exception: Source: Microsoft Excel Description: 'C:\Users\User\Documents\MATLAB\C:\Users\User\Dropbox\MATLAB\002 Human Machine\v6_1\results_20131102_222147.xlsx' could not be found. Check the spelling of the file name, and verify that the file location is correct.</p>
  
  <p>If you are trying to open the file from your list of most recently used files, make sure that the file has not been renamed, moved, or deleted. Help File: xlmain11.chm Help Context ID: 0</p>
  
  <p>Error in xlswritefig (line 79) op = invoke(Excel.Workbooks, 'open', [pwd filesep filename]);</p>
  
  <p>Error in calcResults_v6_1 (line 226) xlswritefig(gcf, filename, 'Sheet1', 'E2')</p>
  
  <p>Any thoughts? The file clearly exists because it was created and being written to with data, but the way xlswritefig is written (or the way I'm calling it) won't let me write a figure to the already existing file. </p>
  
  <p>Thanks!</p>