Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-22-2015, 08:12 PM
macropod's Avatar
macropod macropod is offline VB for Word - Need macro to loop each line in a document Windows 7 64bit VB for Word - Need macro to loop each line in a document Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,373
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

The macro equivalent of the wildcard Find/Replace is:


Code:
Sub Demo()
Application.ScreenUpdating = False
With ActiveDocument.Range
  .InsertBefore vbCr
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "^13[0-9]{1,}.^32"
    .Replacement.Text = "^p"
    .Forward = True
    .Wrap = wdFindContinue
    .Format = False
    .MatchWildcards = True
    .Execute Replace:=wdReplaceAll
  End With
  While .Characters.First = vbCr
    .Characters.First.Delete
  Wend
End With
Application.ScreenUpdating = True
End Sub
It's unclear whether you intend to retain a paragraph break between the segments. If not, delete the ^p from the code. Likewise, it's unclear whether you want to remove the space following the number. If not, delete the ^32.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Tags
loop macro, vb, word 2013 lines



Similar Threads
Thread Thread Starter Forum Replies Last Post
VB for Word - Need macro to loop each line in a document macro to add brackets to each line and add single quotes to each word in the line bracketandquotes Word VBA 17 02-16-2015 03:51 PM
Save As Macro using first line of document as document name redzan Word VBA 1 01-31-2015 09:24 PM
VB for Word - Need macro to loop each line in a document Loop through each Line in Word ilcaa72 Word VBA 4 02-13-2014 11:48 AM
VB for Word - Need macro to loop each line in a document Macro to loop in Word Yamaha Rider Word VBA 2 02-07-2012 05:33 PM
VB for Word - Need macro to loop each line in a document WORD Macro - import picture - resize - position - page break - loop Nano07 Word VBA 2 11-02-2011 05:14 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:37 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