PDA

View Full Version : VBA Script to delete first 7 words of each paragraph



mpeterson
08-16-2015, 07:22 AM
Hi Guys,

I'm in the process of forming multiple response questions. In one step of such process I have to delete exactly the first 7 words of each paragraph (which will be the question core). In my questions document I have more than 500 paragraphs.

Can someone help with this request please?

Many thanks in advance.

gmaxey
08-16-2015, 07:22 PM
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oPar As Paragraph
Dim oRng As Range
For Each oPar In ActiveDocument.Paragraphs
Set oRng = oPar.Range
oRng.Collapse wdCollapseStart
oRng.MoveEnd wdWord, 7
oRng.Delete
Next oPar
lbl_Exit:
Exit Sub
End Sub

mpeterson
08-16-2015, 08:37 PM
Please accept my personal gratitude. Thank you very much Greg for your invaluable contribution to this world. All the best.