How do I adjust the pasted text to Word from Notepad or similar p.

G

Guest

I tried to copy a text from Notepad and paste it into Word. Often time after
pasting, I had to readjust its width in Word in order to make it "stretch"
out on the page. Is there any other way I can do it without the adjustment,
so the pasted text can automatically stretch out itself in Word?

Thanks.
 
S

Steve Yandl

The subroutine below will probably do what you want. I wish I could recall
who to credit as the author but I don't.

Sub ClearXtraCarriageReturns()
'
Dim rngStartMarker As Word.Range
Set rngStartMarker = Selection.Range

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "([!^13])(^13)([!^13])"
.Replacement.Text = "\1 \3"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll

rngStartMarker.Select
End Sub


Steve
 

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