Hi,

I am looking to have my macro search for and open up an embedded Excel file in word (eventually to automatically update the excel embed and exit back to the word document)

I want it to stop at the end of the word document, but my code seems to have it continue forever--

Option Explicit
Sub update()

Dim oShape As Shape
Dim EntireLoadLine As String
Dim wdDoc As Word.Document

Do
    Selection.HomeKey unit:=wdLine
    Selection.EndKey unit:=wdLine, Extend:=wdExtend
    EntireLoadLine = Selection
    
    On Error Resume Next
    Set oShape = wdDoc.Shapes
    On Error GoTo 0
    If Not (oShape Is Nothing) Then
    
    For Each oShape In wdDoc.Shapes
        If oShape.Type = msoEmbeddedOLEObject Then
        oShape.OLEFormat.DoVerb verbindex:=wdOLEVerbPrimary
        End If
    Next oShape
    
    Else:
        Selection.MoveDown unit: wdLine , Count:=1
    End If

Loop
End Sub
I have tried adding
Loop Until Not (oShape Is Nothing)
just to have it stop, once it finds my embedded Excel file (in the document), but that doesn't seem to work either.

Any ideas?

Thanks!