Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / August 2007

Tip: Looking for answers? Try searching our database.

How can I programmatically relink OLE's in a Word document

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Cevriye Kuntay - 02 Aug 2007 02:53 GMT
Hi!
I created a Microsoft Word document that contains dozens of linked objects
(OLE's). I am trying to change the path name in the "embedded objects"
within the Word.  I want the macro to scan through each page in the document
and find each embedded object (which are linked to an excel file), then find
the pathname: "C:\drive\documents\file1.xls" and replace it with
"C:\drive\documents\file2.xls".  I have the following as a beginnig point
but I could not finish it. This is my first attempt to write a VBA code. Any
help you could provide will be greatly appreciated. Here is my incomplete
code:

Sub ChangeSource()

Dim k As Long
'Create a variable to store the object reference string.
Dim strLink As String

With ActiveDocument
   ' Loop through all the floating shapes in document.
   For k = 1 To .Shapes.Count
       With .Shapes(k)
           ' If the shape's type is an OLE object then...
           If .Type = msoLinkedOLEObject Then
               ' Change the path to new source and set the update
               ' type to Automatic.
               With .LinkFormat
                   ' Get the source path in a string
                   strLink = .SourceFullName
                   ' Do something to strLink to modify:

                   'Code to modify strLink

                   .SourceFullName = strLink
                   .Update
               End With
         End If
      End With
   Next k

End With
Jean-Guy Marcil - 02 Aug 2007 06:04 GMT
Cevriye Kuntay was telling us:
Cevriye Kuntay nous racontait que :

> Hi!
> I created a Microsoft Word document that contains dozens of linked
[quoted text clipped - 36 lines]
>
> End With

Already answered in the vba.general group.

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.