Sub Initialize
  Dim session As New NotesSession 
  Dim db As NotesDatabase 
  Dim collection As NotesDocumentCollection
  Dim doc As NotesDocument
  Set db = session.CurrentDatabase
  Set collection = db.AllDocuments
  Set doc = collection.GetFirstDocument()
  While Not(doc Is Nothing)  
    If doc.HasEmbedded Then
      Call detachFiles( doc )
    End If
    Set doc = collection.GetNextDocument(doc) 
  Wend
End Sub
Sub detachFiles( doc As NotesDocument )
  Dim rtitem As Variant
  Set rtitem = doc.GetFirstItem( "Body" )
  Forall o In rtitem.EmbeddedObjects
    If o.Type = EMBED_ATTACHMENT Then  
      Call o.ExtractFile( "c:\newfiles\" & o.Source )
      Call o.Remove
      Call doc.Save( True, True )   
    End If
  End Forall
End Sub