+ Reply to Thread
Results 1 to 2 of 2

Word embedded Excel file to open automatically

Hybrid View

Dunctonsteel Word embedded Excel file to... 08-01-2013, 02:26 PM
Kenneth Hobson Re: Word embedded Excel file... 08-01-2013, 03:16 PM
  1. #1
    Registered User
    Join Date
    09-10-2012
    Location
    NY, NY
    MS-Off Ver
    Excel 2010
    Posts
    13

    Word embedded Excel file to open automatically

    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!

  2. #2
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Word embedded Excel file to open automatically

    Seems to me that you only need the For Each loop and not the other parts of the Do loop.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. open and manipulate embedded word documents from excel?
    By mcledavid in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-21-2009, 04:24 PM
  2. exce; macro to open, save embedded pdf, word, excel, ppt files to a folder
    By mcledavid in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-16-2009, 05:17 PM
  3. Replies: 0
    Last Post: 09-16-2009, 05:11 PM
  4. Embedded Excel file in Word
    By QOAT in forum Excel General
    Replies: 1
    Last Post: 03-31-2006, 01:10 PM
  5. Problem opening Excel file > 1 time with embedded Word objects
    By kristineogden@gmail.com in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-03-2005, 04:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1