Tech Support Forum banner

MS Word VBA to Remove Extra Blank Lines

6412 Views 0 Replies 1 Participant Last post by  bmcellis
I have a report in MS Access which I export as RTF. Because of templates etc I thencopy the rtf file and paste it into a template. For some reason I'm getting a bunch of extra blank lines when I do that which creates an extra section break which creates a messed up document. I've found this code to remove extra blank lines but it takes at least 10 minutes per document. Do you have better ideas?

Topic: VBA Examples (Microsoft Word)

suggestions for improvement?

Selection.HomeKey Unit:=wdStory
With Selection.Find
.Text = "^p^p"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
While Selection.Find.Found
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.MoveLeft Unit:=wdCharacter, Count:=2
See less See more
Not open for further replies.
1 - 1 of 1 Posts
1 - 1 of 1 Posts
Not open for further replies.