#1
|
|||
|
|||
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! |
#2
|
|||
|
|||
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) |
#3
|
|||
|
|||
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...
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Removing secondary entries | atilla | Excel | 4 | 07-17-2011 07:29 AM |
Removing Custom XML | Ulodesk | Word | 0 | 06-24-2011 09:01 AM |
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 |