title: Using a loop and saveas to save multiple embedded word documents to C drive (or others)
body: <p>I have a excel sheet with multiple word documents saved in it, and I would like to programatically save them from the excel embedded document to a drive.  I used some code I found here and tried to add a loop for it to go through each document and save, but it errors before the loop completes.  Here is the code:</p>
  
  <pre><code>Sub aaSaveEmbedded1()
  
  Application.ScreenUpdating = False
  
  i = 1
  Do Until i = 10
  
  
  Dim num As String
  num = Cells(i + 9, 4).Value
  Dim nam As String
  nam = Cells(i + 9, 8).Value &amp; ".doc"
  Dim sh1 As Shape
  Dim objWord As Object ''Word.Document
  Dim objOLE As OLEObject
  
  ''The shape holding the object from 'Create from file'
  
  Set sh1 = ActiveSheet.Shapes(i)
  
  ''Activate the contents of the object
  sh1.OLEFormat.Activate
  
  ''The OLE Object contained
  Set objOLE = sh1.OLEFormat.Object
  
  ''This is the bit that took time
  Set objWord = objOLE.Object
  
  ''Save it
  objWord.SaveAs2 Filename:="C:\Users\rchandler\Desktop\condor project\Procedures\1_Drilling Procedures\" &amp; num &amp; nam, _
  FileFormat:= _
  wdFormatTemplate  ''1=wdFormatTemplate
  
  
  objWord.Application.Quit
  Set objWord = Nothing
  Set sh1 = Nothing
  Set objOLE = Nothing
  num = Empty
  nam = Empty
  
  i = i + 1
  
  Loop
  
  Application.ScreenUpdating = True
  
  End Sub
  </code></pre>
  
  <p>When I run the code the first iteration works and the first document is saved.  After that I get a error stating "Cannot start the source application for this object" on this line:</p>
  
  <p>sh1.OLEFormat.Activate</p>
  
  <p>I just started to use VBA this week, and I do not have very much experience programming so any help will be greatly appreciated.  It takes me a long time to fix problems atm.  Thanks in advance.</p>