Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / October 2007

Tip: Looking for answers? Try searching our database.

deleting blank spaces

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
gaubahn - 23 Oct 2007 08:33 GMT
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
Greg Maxey - 23 Oct 2007 13:19 GMT
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

Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

> Hi Guys,
>
[quoted text clipped - 33 lines]
> Thanks and regards,
> gaubahn
Russ - 23 Oct 2007 19:03 GMT
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.

> Hi Guys,
>
[quoted text clipped - 30 lines]
> Thanks and regards,
> gaubahn

Signature

Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID

gaubahn - 25 Oct 2007 08:34 GMT
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,
>
[quoted text clipped - 19 lines]
>> Thanks and regards,
>> gaubahn

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.