title: PowerPoint VBA - Paste Special (Enhanced Metafile) bug
body: <p>I am using a macro in PowerPoint 2003 SP3 to find a specified chart in an Excel workbook, copy it, and then paste it into the current slide as an Enhanced Metafile with, ultimately, the following line of code:</p>
  
  <p><pre><code>Application.ActiveWindow.View.PasteSpecial DataType:=ppPasteEnhancedMetafile</pre></code></p>
  
  <p>As often as it works, I also receive the following error:
  <p></p>
  
  <pre>Run-time error '-2147188160 (80048240)':
  View (unknown member) : Invalid request. The specified data type is unavailable.</pre>
  
  <p>If I end the macro and attempt to manually Paste Special as Enhanced Metafile, I have no problem, so it's not as though the clipboard object or the pastespecialtype is invalid.</p>
  
  <p>Has anyone else experienced this? Do you have a solution or a workaround? There are few results and no solutions in a Google search on this error.</p>
  
  <hr>
  
  <p><b>Update</b></p>
  
  <p>The general code is as follows:</p>
  
  <pre><code>Set presPPTCurrent = ActivePresentation
  Set objXLApp = GetObject(, "Excel.Application")
  
  ''#Find the target chart and copy it to the clipboard
  With objXLApp
      ''#This part works - if I go to Excel, I can see that the chart is copied
  End With
  
  ''#Now paste in the chart as an Enhanced Metafile
  presPPTCurrent.Application.Activate
  Application.ActiveWindow.View.PasteSpecial DataType:=ppPasteEnhancedMetafile
  </code></pre>
  
  <p>Note that this is in a Sub to which a Shape is passed (the Shape being passed is used as a reference to find the chart in Excel). I've realized that it only bugs when I attempt to reuse this sub on multiple shapes passed from a For Next loop in another Sub.</p>
  
  <p>However, if I pass a single Shape to this Sub with via another Sub and then re-run the Sub that passes multiple Shapes, it runs fine.</p>
  
  <hr>
  
  <p><b>Solution</b></p>
  
  <p>Per Otaku's mention, the macro was losing its focus on the Slide Pane. Telling it to re-select the Slide Pane solved the issue.</p>
  
  <p><pre><code>Application.ActiveWindow.Panes(2).Activate</pre></code></p>