View Single Post
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Jezebel Jezebel is offline
external usenet poster
 
Posts: 1,384
Default Macro to Break Links to Excel in Document Header

WholeStory refers only to the body of the document (ie not the header). If
you have fields in other StoryRanges you need to deal with them
separately --

Dim pRange As Word.Range
For each pRange in ActiveDocument.StoryRanges
Do
pRange.Fields.Unlink
Set pRange = pRange.NextStoryRange
Loop Until pRange is Nothing
Next

This will get everything except fields in textboxes in headers and footers.
Post again if you need to deal with them too.





"mt_pelion" wrote in message
...
I am using Word 2000 and Excel 2000.
I have created a Word file as a template file which uses links to an Excel
file to create a checklist with client date already on it. I have a macro
already in the document which does *almost* everything I need it to. Here
is
my current macro:
Sub AutoOpen()
Selection.WholeStory
Selection.Fields.Unlink
Selection.HomeKey Unit:=wdStory
Application.Dialogs(wdDialogFileSaveAs).Show
End Sub

What is supposed to happen is this:
1. Open the Excel file and enter all the data in the highlighted fields.
2. Save the master excel file and close Excel.
3. Open the Word file.
4. The Word File will automatically update the links with the data, remove
the links, and load the Save As... screen.
5. Save the file to the client's folder and close Word.

Unfortunately, I have found that this does not remove links in the header
of
the document. Links in the body are successfully removed, however. This,
of
course, causes problems when the client's saved Word files are opened
later
as the headers then automatically update to the most recent entries in the
master Excel file.

Can anyone tell me what I need to add or change in my macro to fix this?

Thanks!