View Single Post
 
Old 01-03-2015, 01:21 PM
ptmuldoon ptmuldoon is offline Windows 7 64bit Office 2013
Advanced Beginner
 
Join Date: Sep 2014
Posts: 93
ptmuldoon is on a distinguished road
Default

Thanks

I was just about to post back as well when I found your answer. From some code from Macropod, and testing recording a macro, I learned to do a search and select the text to replace it like this as well.

Code:
Sub FindMyWords()
Application.ScreenUpdating = False
Dim strWords As String, i, j As Integer
strWords = "C:\\Data\\"
j = 0

  With ActiveDocument.Content
    With .Find
      .Text = strWords
      .Wrap = wdFindStop
      .Format = False
      .MatchCase = False
      .MatchWholeWord = True
      .MatchWildcards = False
      .MatchSoundsLike = False
      .MatchAllWordForms = False
      .Execute
    End With
    Do While .Find.Found
      j = j + 1
      .Select
      
      Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
        "DOCPROPERTY  WPFilePath ", PreserveFormatting:=True
      .Find.Execute
    Loop
  End With

MsgBox j & " instances found."
Application.ScreenUpdating = True
End Sub
So both solutions work.

I did find that if you update the OLE links, you do lose the Field Code as it gets converted to the value. But that is ok, I was looking to change them all so that I can then save the entire OLE link with the fieldcode as a building block.
Reply With Quote