Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-26-2018, 07:08 AM
Ktulu Ktulu is offline Delete starting and ending character of a line Windows 7 32bit Delete starting and ending character of a line Office 2007
Novice
Delete starting and ending character of a line
 
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
  #2  
Old 04-26-2018, 07:15 AM
slaycock slaycock is offline Delete starting and ending character of a line Windows 7 64bit Delete starting and ending character of a line Office 2016
Expert
 
Join Date: Sep 2013
Posts: 256
slaycock is on a distinguished road
Default

It could be as simple as doing

':^p' replaced with '^p'

And

'^p:' replaced with '^p'
Reply With Quote
  #3  
Old 04-26-2018, 09:59 AM
Ktulu Ktulu is offline Delete starting and ending character of a line Windows 7 32bit Delete starting and ending character of a line Office 2007
Novice
Delete starting and ending character of a line
 
Join Date: Apr 2018
Posts: 6
Ktulu is on a distinguished road
Default

Quote:
Originally Posted by slaycock View Post
It could be as simple as doing

':^p' replaced with '^p'

And

'^p:' replaced with '^p'
Thank you so much!
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Error with macro to delete starting #) [code included] puff Word VBA 1 04-18-2018 03:49 PM
Delete starting and ending character of a line Delete Character on Single Line Only Tye30 Word VBA 8 04-20-2017 08:40 PM
Delete account and starting again? ethelthefrog Outlook 0 02-16-2015 01:23 PM
Delete starting and ending character of a line Delete starting number *) and delete Unneeded data in series frustrated teacher Word VBA 5 12-07-2014 06:53 PM
Delete starting and ending character of a line Add text to the beginning/ending of each line in word ballmoney Word 1 01-17-2010 02:19 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:03 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft