To insert 2 spaces after full stop or end of sentence or paragraph

P

Paresh

Can any one give me macro syntax to do the following:

1. To insert 2 spaces after every full stop or end of sentence or end of
paragraph(just before para return sign)

2. The above should work for text in Tables also.

Thanks in advance.
 
G

Greg

Try something like:

Public Sub Scratch Macro()

Dim rngStory As Word.Range
' Fix the skipped blank Header/Footer problem
MakeHFValid
' Iterate through all story types in the current document
For Each rngStory In ActiveDocument.StoryRanges
' Iterate through all linked stories
Do Until (rngStory Is Nothing)
With rngStory.Find
.ClearFormatting
.Replacement.ClearFormatting
.MatchWildcards = True
.Text = "([:.,\!\?]) ([! ])":
.Replacement.Text = "\1 \2"
.Execute Replace:=wdReplaceAll
End With
Set rngStory = rngStory.NextStoryRange
Loop
Next
End Sub
Public Sub MakeHFValid()
Dim lngJunk As Long
lngJunk = ActiveDocument.Sections(1).Headers(1).Range.StoryType
End Sub
 
P

Paresh

Greg:

Thanks once again! But this macro does not help me in end of paragraph
returns.

Regards
Paresh
 
G

Greg

Not sure I follow, but try:

Option Explicit
Public Sub ScratchMacro()

Dim rngStory As Word.Range
' Fix the skipped blank Header/Footer problem
MakeHFValid
' Iterate through all story types in the current document
For Each rngStory In ActiveDocument.StoryRanges
' Iterate through all linked stories
Do Until (rngStory Is Nothing)
With rngStory.Find
.ClearFormatting
.Replacement.ClearFormatting
.MatchWildcards = True
.Text = "([:.,\!\?\^13]) ([! ])":
.Replacement.Text = "\1 \2"
.Execute Replace:=wdReplaceAll
.Text = "(?)(^13)"
.Replacement.Text = "\1 \2"
.Execute Replace:=wdReplaceAll
End With
Set rngStory = rngStory.NextStoryRange
Loop
Next
End Sub
Public Sub MakeHFValid()
Dim lngJunk As Long
lngJunk = ActiveDocument.Sections(1).Headers(1).Range.StoryType
End Sub
 

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