Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
Luke Luke is offline
external usenet poster
 
Posts: 34
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Luke Luke is offline
external usenet poster
 
Posts: 34
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Luke Luke is offline
external usenet poster
 
Posts: 34
Default 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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Count phrase that spans two lines Amy Microsoft Word Help 3 January 31st 09 09:00 PM
word or phrase selection highlight colour Avery Tom Deacon Harry Microsoft Word Help 1 June 23rd 08 03:49 AM
In doc file how do I highlight a word but not print highlight? Sheilaj7 Microsoft Word Help 1 June 20th 08 03:06 AM
How do I stop a phrase from being broken across two lines? Amanda Llewellyn Microsoft Word Help 5 May 19th 05 02:19 PM
Highlight phrase won't drag and drop rob_regent Microsoft Word Help 2 May 7th 05 05:45 PM


All times are GMT +1. The time now is 12:11 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"