Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-17-2014, 11:17 AM
sbktex sbktex is offline search for string, wherever found, at end of line, insert 8 <cr>s Windows 7 64bit search for string, wherever found, at end of line, insert 8 <cr>s Office 2007
Novice
search for string, wherever found, at end of line, insert 8 <cr>s
 
Join Date: Sep 2014
Location: North Texas
Posts: 1
sbktex is on a distinguished road
Default SOLVED: search for string, wherever found, at end of line, insert 8 <cr>s

we do a single drag/copy/paste text from a proprietary app's text window and paste into a blank word page. it can be from a dozen lines to a few hundred lines. when in Word, we see each line has a paragraph mark.

we need to search the whole block and whenever we see a set text sting (thankfully unique i.e "KKJJ ABC") we need to go to the end of that line and insert 8 carriage returns. do until end. end product is 8 blank lines after each incidence of the string.



i have put in buckets of BS&T manipulating Excel code, but those few different concepts of Word VBA still escape me at the moment. we needed this yesterday, and i just can't get the search,move,do, repeat individual parts to work together.

Any help, extremely thankful.. -- Scott

Last edited by sbktex; 09-18-2014 at 10:57 AM. Reason: SOLVED
Reply With Quote
  #2  
Old 09-17-2014, 12:17 PM
gmaxey gmaxey is offline search for string, wherever found, at end of line, insert 8 &lt;cr&gt;s Windows 7 32bit search for string, wherever found, at end of line, insert 8 &lt;cr&gt;s Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,422
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Code:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oPar As Paragraph
  For Each oPar In ActiveDocument.Paragraphs
    If InStr(oPar.Range.Text, "KKJJ ABC") > 0 Then oPar.Range.InsertAfter String(8, vbCr)
  Next oPar
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #3  
Old 09-17-2014, 04:09 PM
macropod's Avatar
macropod macropod is offline search for string, wherever found, at end of line, insert 8 &lt;cr&gt;s Windows 7 64bit search for string, wherever found, at end of line, insert 8 &lt;cr&gt;s Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Cross-posted and answered 3 weeks ago at: http://www.excelforum.com/word-progr...t-in-line.html
For cross-posting etiquette, please read: http://www.excelguru.ca/content.php?184
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
search for string, wherever found, at end of line, insert 8 &lt;cr&gt;s Search first section for specific string... donaldadams1951 Word VBA 4 03-14-2014 11:24 AM
search for string, wherever found, at end of line, insert 8 &lt;cr&gt;s Way to search for a string in text file, pull out everything until another string? omahadivision Excel Programming 12 11-23-2013 12:10 PM
search for string, wherever found, at end of line, insert 8 &lt;cr&gt;s Macro to create new word doc and save the file using String found in the document VBNation Word VBA 2 02-08-2013 07:14 AM
Excel Fomula to search for a string and display value from different column zeeshanbutt Excel 1 07-29-2012 12:48 AM
search for string, wherever found, at end of line, insert 8 &lt;cr&gt;s Bad view when using Find and Find & Replace - Word places found string on top line paulkaye Word 4 12-06-2011 11:05 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:30 PM.


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