Thread: [Solved] copy a paragraph
View Single Post
 
Old 12-12-2024, 12:01 AM
yacov yacov is offline Windows 10 Office 2016
Competent Performer
 
Join Date: Oct 2019
Posts: 146
yacov is on a distinguished road
Default copy a paragraph

Hi,
I have been using this macro for a long time to copy a paragraph. Recently it has stopped working and is giving an error message: run time eroro 4605
Does anyone have any idea what happened
Thanks a lot.



Sub COPYPAR()
'Copy a range from the current para's start till after "=" and
'paste it after the para.

Dim oRng As Range
Set oRng = Selection.Paragraphs(1).Range
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With oRng.Find
.Text = "="
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
If .Execute Then
oRng.Start = Selection.Paragraphs(1).Range.Start
oRng.Copy
Selection.Paragraphs(1).Range.Select
Selection.Collapse wdCollapseEnd
Selection.InsertAfter vbCr
Selection.Collapse
Selection.PasteAndFormat (wdFormatOriginalFormatting)
End If
End With
End Sub
Reply With Quote