Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-22-2011, 04:40 PM
digitalhecht digitalhecht is offline Removing Character Strings Windows 7 64bit Removing Character Strings Office 2007
Novice
Removing Character Strings
 
Join Date: Sep 2011
Posts: 2
digitalhecht is on a distinguished road
Default Removing Character Strings

Hi All,


I am an admitted newbie with MS Office and don't even know if that's the right terminology in the subject line. So here goes...
I have a 99 page Word doc of over 700 (Twitter) tweets in which I would like to do a Replace (deletion, actually) for all date/time stamps, all returns, and all URLS. So that this below:

2011-05-13 18:56:15
http://cnet.co/k0kvkG Sorry, but unless it's from their own
home, anyone who broadcasts their location in real-time is an idiot.

2011-05-13 18:45:35
Sorry, (PC/Android) tablet makers: iPad (2) is STILL King of
the Hill-over a year later.


Will look like this:

Sorry, but unless it's from their own
home, anyone who broadcasts their location in real-time is an idiot.
Sorry, (PC/Android) tablet makers: iPad (2) is STILL King of
the Hill-over a year later.


(Almost all URLs have been shortened by bit.ly.) Many thanks in advance!
Reply With Quote
  #2  
Old 09-26-2011, 04:45 AM
OTPM OTPM is offline Removing Character Strings Windows 7 32bit Removing Character Strings Office 2010 32bit
Expert
 
Join Date: Apr 2011
Location: West Midlands
Posts: 981
OTPM is on a distinguished road
Default

Hi
This is fairly basic vba code but it does the trick. Copy and paste the code below into a module in your document and run it. There may be more efficient and streamlined options from vba experts but see how you go.

Sub Search_and_Replace()
'
' Search_and_Replace Macro
' Macro recorded 9/26/2011 by Anthony R.G. King
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^l^l"
.Replacement.Text = "^p"
.Forward = True
.Wrap = wdFindContinue
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "^l"
.Replacement.Text = " "
.Forward = True
.Wrap = wdFindContinue
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "([0-9])"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "-- ::"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Style = ActiveDocument.Styles("Hyperlink")
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = " "
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = " "
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "^p "
.Replacement.Text = "^p"
.Forward = True
.Wrap = wdFindContinue
End With
End Sub

Good luck.
Tony(OTPM)
Reply With Quote
  #3  
Old 10-17-2011, 12:53 PM
digitalhecht digitalhecht is offline Removing Character Strings Windows 7 64bit Removing Character Strings Office 2007
Novice
Removing Character Strings
 
Join Date: Sep 2011
Posts: 2
digitalhecht is on a distinguished road
Default

Thanks for your response, OTPM. I wasn't able to get it tow work, unfortunately. I ended up doing it manually. Luckily, this is a once in several years endeavor...
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Removing Character Strings Removing secondary entries atilla Excel 4 07-17-2011 07:29 AM
Removing Custom XML Ulodesk Word 0 06-24-2011 09:01 AM
Removing Character Strings update style of all strings available between two specific strings vikrantkale Word 1 03-28-2011 06:13 PM
Removing All Formating basscarp Word 0 01-31-2010 05:49 PM
Regex in Word: Replaced strings are in disorder chgeiselmann Word 0 04-26-2009 11:33 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:01 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