Hi all,
I hope someone can help me with this. I have some code that looks for a specific symbol in a word document, and then paste that line into a new document. If there are e.g. 3 of the same symbol next to each other, it will copy the same line 3 times, e.g:
Sample list:
pen
book #
desk ###
pencil
It needs to paste the following into the new word document:
book
3 x desk
At the moment, it is writing the word 'desk' three times underneath each other. I have had some help putting the code together, but I am now stuck again on how to streamline it.
I hope it all makes sense.
Code:
This is the code I have so far:
With oRng.Find
Do While .Execute(findText:="#")
oRng.MoveEndWhile Chr(32)
Set oPara = oRng.Paragraphs(1).Range
oTarget.Range.InsertAfter (Trim(Replace(oPara.Text, "#", "")))
oRng.Text = ""
oRng.Collapse 0
Loop
End With