Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 06-19-2018, 09:28 AM
moorea21 moorea21 is offline Macro to append text to end of paragraphs/lines where target text is found. Windows 7 64bit Macro to append text to end of paragraphs/lines where target text is found. Office 2010 64bit
Novice
Macro to append text to end of paragraphs/lines where target text is found.
 
Join Date: Jun 2018
Posts: 8
moorea21 is on a distinguished road
Default Macro to append text to end of paragraphs/lines where target text is found.

Hi,


I am trying to use this code:-


Sub Rpl()
Dim singleLine As Paragraph
Dim lineText As String
Dim MyPos

For Each singleLine In ActiveDocument.Paragraphs
lineText = singleLine.Range.Text

MyPos = InStr(lineText, "Test Text")
'If MyPos = 1 Then Replace(lineText , lineText & "LxW ")
If MyPos = 1 Then lineText = lineText & "LxW "


Next singleLine
End Sub


Although the value of 'lineText' gets updated, it doesn't replace it in the document, so I tried a VB6 'replace' function, which is invalid. How would I get the new value of lineText to replace the old value in the document?


Thanks
Reply With Quote
 

Tags
append, replace, vb6



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to append text to end of paragraphs/lines where target text is found. Macro to hide all paragraphs that do not have the found result jplat Word VBA 1 09-10-2017 09:13 PM
Delete Text from Insertion Point to Found Text feenyman99 Word 0 04-17-2016 05:40 PM
Macro to append text to end of paragraphs/lines where target text is found. Macro to color row of Word table based on found text kristib Word VBA 4 11-15-2015 02:42 PM
Macro to append text to end of paragraphs/lines where target text is found. Macro to Insert text into the beginning on specific paragraphs unless the paragraph is blank caboy Word VBA 2 04-01-2015 07:00 AM
Macro to Insert Text Into Cells Having Multiple Lines revans611 Excel Programming 4 10-24-2011 10:15 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:53 PM.


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