Break OLE links in Word

W

Webmaestro

Does anyone know hw to programmatically "Break Links" in Word to an Excel
spreadsheet? I have multiple links at different points in a document that is
used as a template to produce a final report (as a new file). I want to
ensure that once the report is completed (programmatically) that all the
links are broken so that when it (the new file) is opened again no further
updating will be done.

Thx.
 
D

Doug Robbins - Word MVP

Dim afield As Field
For Each afield In ActiveDocument.Fields
If afield.Type = wdFieldLink Then
afield.Unlink
End If
Next afield


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
W

Webmaestro

Hi Doug,

Thanks for that - it worked beautifully. I had found some other code that
was not as elegant and needed other checks. Tried your code and bingo -
simple as pie! I had to use it in the form:

Word.wdFieldLink

since I was caling the macro from Excel

Thanks again.

Bob Lewis
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top