Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 12-30-2019, 05:42 PM
gmaxey gmaxey is offline VBA to find text, replace with multiple lines of text Windows 10 VBA to find text, replace with multiple lines of text Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
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
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Find and replace header text across multiple files LG1972 Excel 1 12-25-2018 04:27 AM
VBA to find text, replace with multiple lines of text Find & Replace text in Field Code across multiple documents RPM7 Word VBA 6 05-12-2017 12:58 AM
VBA to find text, replace with multiple lines of text Need assistance to find and replace text within headers/footers in excel - multiple worksheets teddycatnc Excel 3 03-07-2016 12:04 AM
Macro to find coloured text and replace with form-field/formtext containing that text tarktran Word VBA 1 11-26-2014 08:12 AM
VBA to find text, replace with multiple lines of text Find and Replace multiple lines/paragraphs jcw Word 1 11-18-2011 11:47 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:52 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft