deleting blank spaces

  • Thread starter gaubahn via OfficeKB.com
  • Start date
G

gaubahn via OfficeKB.com

Hi Guys,

I have output documents that have extra blank line spaces that have a size of
2pt. I am trying to create a macro that should delete all instances of this
2pt size line spaces. However my macro below only works to some extent, when
a document have two blank lines that are both in size 2, it only deletes 1
blank space. If i run the macro again it still does not remove the the
remaining blank line space.

Sub Delete2ptLineSpace()
With ActiveDocument.Content.Find
.ClearFormatting
.Replacement.ClearFormatting
With .Font
.Size = 2
End With
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
End With
End Sub

i would greatly appreciate any assistance regarding this.

Thanks and regards,
gaubahn
 
G

Greg Maxey

This should work:

Sub ScratchMacro()
Dim oPar As Paragraph
For Each oPar In ActiveDocument.Range.Paragraphs
If Len(oPar.Range.Text) = 1 And oPar.Range.Font.Size = 8 Then
oPar.Range.Delete
End If
Next
End Sub
 
R

Russ

Gaubahn,

This will remove all paragraph marks with that size:
Public Sub Delete2ptLineSpace()
With ActiveDocument.Content.Find
.Font.Size = 2
.Text = "^13" '\n on a Mac
.Replacement.Text = ""
.MatchWildcards = True
.Execute Replace:=wdReplaceAll
End With
End Sub

Note: The normal way to space between paragraphs in Word is not with extra
blank lines, but by using properties of paragraphs called space before and
space after. Styles can be set up to easily apply those paragraph
properties.
 
G

gaubahn via OfficeKB.com

Hi Greg and Russ,

Thank you very much for your help I was finally able to get rid of the blank
spaces.

Thanks and regards,
gau
Gaubahn,

This will remove all paragraph marks with that size:
Public Sub Delete2ptLineSpace()
With ActiveDocument.Content.Find
.Font.Size = 2
.Text = "^13" '\n on a Mac
.Replacement.Text = ""
.MatchWildcards = True
.Execute Replace:=wdReplaceAll
End With
End Sub

Note: The normal way to space between paragraphs in Word is not with extra
blank lines, but by using properties of paragraphs called space before and
space after. Styles can be set up to easily apply those paragraph
properties.
[quoted text clipped - 30 lines]
Thanks and regards,
gaubahn
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top