Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Highlight all lines containing phrase
Hi All,
In word 2007 I have a very large file open which is lines of a backup script. I am trying to isolate all of the lines which start with the phrase 'source=' and highlight them. In this way I can copy them and paste them into a new document, which will just show me all of the source folders, making it easier for me to go through what we are backing up. I know I can find all and highlight the 'source=' phrase with reading highlight, but I cant copy all of those.. and it also wont highlight the whole line.. it only highlights the phrase 'source='. Does anyone know if its possible to do what I am trying to do and if so.. how? Cheers, Luke |
#2
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Highlight all lines containing phrase
Use a macro containing the following code:
Dim source As Document, target As Document Set source = ActiveDocument Set target = Documents.Add source.Activate Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(FindText:="source=", Forward:=True, _ MatchWildcards:=False, Wrap:=wdFindStop, MatchCase:=False) = True target.Range.InsertAfter Selection.Bookmarks("\line").Range.Text & vbCr Selection.Collapse wdCollapseEnd Selection.MoveRight wdCharacter, 1 Loop End With target.Activate While it does not do exactly what you asked for, I believe that it gives you what you want. -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP, originally posted via msnews.microsoft.com "Luke" wrote in message news Hi All, In word 2007 I have a very large file open which is lines of a backup script. I am trying to isolate all of the lines which start with the phrase 'source=' and highlight them. In this way I can copy them and paste them into a new document, which will just show me all of the source folders, making it easier for me to go through what we are backing up. I know I can find all and highlight the 'source=' phrase with reading highlight, but I cant copy all of those.. and it also wont highlight the whole line.. it only highlights the phrase 'source='. Does anyone know if its possible to do what I am trying to do and if so.. how? Cheers, Luke |
#3
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Highlight all lines containing phrase
Thanks for your response! However I dont know anything about Macros.. I tried
pasting this into the macros window in word 2007 but I get a 'compile error: invalid outside procedure' I had a look at help but I think I actually got dumber trying to figure out what is going on Could you let me know where this code goes to make it work? Thanks again for your help "Doug Robbins - Word MVP" wrote: Use a macro containing the following code: Dim source As Document, target As Document Set source = ActiveDocument Set target = Documents.Add source.Activate Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(FindText:="source=", Forward:=True, _ MatchWildcards:=False, Wrap:=wdFindStop, MatchCase:=False) = True target.Range.InsertAfter Selection.Bookmarks("\line").Range.Text & vbCr Selection.Collapse wdCollapseEnd Selection.MoveRight wdCharacter, 1 Loop End With target.Activate While it does not do exactly what you asked for, I believe that it gives you what you want. -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP, originally posted via msnews.microsoft.com "Luke" wrote in message news Hi All, In word 2007 I have a very large file open which is lines of a backup script. I am trying to isolate all of the lines which start with the phrase 'source=' and highlight them. In this way I can copy them and paste them into a new document, which will just show me all of the source folders, making it easier for me to go through what we are backing up. I know I can find all and highlight the 'source=' phrase with reading highlight, but I cant copy all of those.. and it also wont highlight the whole line.. it only highlights the phrase 'source='. Does anyone know if its possible to do what I am trying to do and if so.. how? Cheers, Luke |
#4
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Highlight all lines containing phrase
It's like Doug gave you the filling for a sandwich and left you to supply the
bread. It needs a "Sub" line at the beginning and an "End Sub" line at the end. Follow the instructions at http://www.gmayor.com/installing_macro.htm to get this working. -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. On Wed, 5 Aug 2009 17:42:01 -0700, Luke wrote: Thanks for your response! However I dont know anything about Macros.. I tried pasting this into the macros window in word 2007 but I get a 'compile error: invalid outside procedure' I had a look at help but I think I actually got dumber trying to figure out what is going on Could you let me know where this code goes to make it work? Thanks again for your help "Doug Robbins - Word MVP" wrote: Use a macro containing the following code: Dim source As Document, target As Document Set source = ActiveDocument Set target = Documents.Add source.Activate Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(FindText:="source=", Forward:=True, _ MatchWildcards:=False, Wrap:=wdFindStop, MatchCase:=False) = True target.Range.InsertAfter Selection.Bookmarks("\line").Range.Text & vbCr Selection.Collapse wdCollapseEnd Selection.MoveRight wdCharacter, 1 Loop End With target.Activate While it does not do exactly what you asked for, I believe that it gives you what you want. -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP, originally posted via msnews.microsoft.com "Luke" wrote in message news Hi All, In word 2007 I have a very large file open which is lines of a backup script. I am trying to isolate all of the lines which start with the phrase 'source=' and highlight them. In this way I can copy them and paste them into a new document, which will just show me all of the source folders, making it easier for me to go through what we are backing up. I know I can find all and highlight the 'source=' phrase with reading highlight, but I cant copy all of those.. and it also wont highlight the whole line.. it only highlights the phrase 'source='. Does anyone know if its possible to do what I am trying to do and if so.. how? Cheers, Luke |
#5
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Highlight all lines containing phrase
Thank you both very much for your help!!! A bit of fiddling around with the
macro thingy and it works now.. Excellent |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Count phrase that spans two lines | Microsoft Word Help | |||
word or phrase selection highlight colour | Microsoft Word Help | |||
In doc file how do I highlight a word but not print highlight? | Microsoft Word Help | |||
How do I stop a phrase from being broken across two lines? | Microsoft Word Help | |||
Highlight phrase won't drag and drop | Microsoft Word Help |