I am trying to create a macro that will break all existing OLE links in a MS Word 2002 document

The master document containes a series of OLE links to text (paragraphs) in other documents. I want to break the links in the master doc so it is only static text. When I record amacro - all document oiperations are captured in teh macro except the Edit>Links... dialog is not captured

I have tried using the following code with no success (perhaps shapes are not word documents?

Dim shapeLoop As Shap
For Each shapeLoop In ActiveDocument.Shape
With shapeLoo
If .Type = msoLinkedOLEObject The
.LinkFormat.Updat
.LinkFormat.BreakLin
End I
End Wit
Next shapeLoo

Any ideas on how to craete this generic macro

Thanks

Mark McFarlane

Re: can't capture Edit>Links... in word macro by Peter

Peter
Sat Jan 24 23:30:15 CST 2004

Hi Mark

Even though you're referring to a Master document I'm taking from what else
you say that it not a real Master/Subdocument(s) were dealing with?

If the files were inserted using Insert/File menu option, then INCLUDETEXT
fields are inserted. If this is the case then you can unlink them using
this code:

Sub UnlinkTextFields()
Dim rngStory As Word.Range
Dim lngIndex As Long

' Iterate through all story types
For Each rngStory In ActiveDocument.StoryRanges

Do Until rngStory Is Nothing

' Do this backwards as we are using the fields
' index and deleteing fields from the same collection at
' the same time
For lngIndex = rngStory.Fields.Count To 1 Step -1
With rngStory.Fields(lngIndex)
If .Type = wdFieldIncludeText Then
.Unlink
End If
End With
Next

' There may be linked stories so make sure we get them as well
Set rngStory = rngStory.NextStoryRange
Loop
Next
End Sub

You can check on the type of field by toggling field code on by selecting
the field and pressing Shift+F9.

If I've missed the mark please explain how subdocuments were inserted.

HTH + Cheers - Peter



"=?Utf-8?B?bWFyayBtY2ZhcmxhbmU=?=" <mark.mcfarlane(at)aramco.com(nospam)>
wrote in news:11D3556C-FEB0-46D8-A195-BF3D46872E28@microsoft.com:

> I am trying to create a macro that will break all existing OLE links in
> a MS Word 2002 document.
>
> The master document containes a series of OLE links to text (paragraphs)
> in other documents. I want to break the links in the master doc so it
> is only static text. When I record amacro - all document oiperations
> are captured in teh macro except the Edit>Links... dialog is not
> captured.
>
> I have tried using the following code with no success (perhaps shapes
> are not word documents?)
>
> Dim shapeLoop As Shape
> For Each shapeLoop In ActiveDocument.Shapes
> With shapeLoop
> If .Type = msoLinkedOLEObject Then
> .LinkFormat.Update
> .LinkFormat.BreakLink
> End If
> End With
> Next shapeLoop
>
> Any ideas on how to craete this generic macro?
>
> Thanks,
>
> Mark McFarlane