View Single Post
 
Old 12-30-2019, 05:42 PM
gmaxey gmaxey is offline Windows 10 Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,601
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Well TabValue (assuming that has been set to the value of your long string of replacement text) is too long for a Replacement.Text property.

You could have that long string set somewhere in the document e.g., a bookmark named "bmText" and use:

Code:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oRng As Range
Dim strFind As String
Dim strReplace As String
  strFind = "<<testtag>>"
  Set oRng = ActiveDocument.Range
  With oRng.Find
    .Text = strFind
    While .Execute
      oRng.Text = ActiveDocument.Bookmarks("bmText").Range.Text
      oRng.Collapse wdCollapseEnd
    Wend
  End With
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote