View Single Post
 
Old 04-26-2018, 07:08 AM
Ktulu Ktulu is offline Windows 7 32bit Office 2007
Novice
 
Join Date: Apr 2018
Posts: 6
Ktulu is on a distinguished road
Default Delete starting and ending character of a line

How to delete starting and ending character of a line.
I have documents in which each line starts and ends with ":"
How do I delete them without deleting other ":" in the document.
I tried this code to remove ":" from the beginning of a line but it deletes the entire line.

Sub CleanUp()
Dim oRng As Word.Range
Set oRng = ActiveDocument.Range
With oRng.Find
.Text = "'"
While .Execute
With oRng.Paragraphs(1).Range
If .Characters(1) = "'" Then .Delete
End With
Wend
End With
End Sub

I recorded my "Illiterate_In_Programming" macro using home, end, backspace, delete and arrow keys but it deletes paragraph formatting. Thanks a lot!!

Would you please recommend a book to learn VBA in word?
Reply With Quote