Group:  Microsoft Word ยป microsoft.public.word.docmanagement
Thread: Finding All Words with Specific Format -- via Macro

Geek News

Finding All Words with Specific Format -- via Macro
Dogwoodnc 12/11/2008 7:07:01 PM
I'm trying to create a macro that will:
a) Find all words/terms in a doc that are formatted blue
b) Copy those words/terms and paste them into a (new) blank document

I've been able to do this manually (via Find/ Highlight All Occurrences/
Format(Font)/ Find All/ Copy/ New Doc/ Paste). However, I have not been able
to get a macro to contain these commands.

Any suggestions??

THANKS in advance!
RE: Finding All Words with Specific Format -- via Macro
Dogwoodnc 12/11/2008 7:42:19 PM
I forgot to mention -- we're using Word 2003, with XP operating system.

Thanks!

"Dogwoodnc" wrote:

[Quoted Text]
> I'm trying to create a macro that will:
> a) Find all words/terms in a doc that are formatted blue
> b) Copy those words/terms and paste them into a (new) blank document
>
> I've been able to do this manually (via Find/ Highlight All Occurrences/
> Format(Font)/ Find All/ Copy/ New Doc/ Paste). However, I have not been able
> to get a macro to contain these commands.
>
> Any suggestions??
>
> THANKS in advance!
Re: Finding All Words with Specific Format -- via Macro
"Graham Mayor" <gmayor[ at ]REMOVETHISmvps.org> 12/12/2008 6:37:54 AM
How about

Sub CopyBlueToOtherDoc()
Dim Source As Document
Dim Target As Document
Dim oRng As Range
Dim sView As String
Set Source = ActiveDocument
sView = ActiveWindow.View.ShowFieldCodes
Set Target = Documents.Add
Application.ScreenUpdating = False
Source.Activate
With Selection
.HomeKey Unit:=wdStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Font.Color = wdColorBlue
Do While .Execute(findText:="", _
MatchWildcards:=False, Wrap:=wdFindStop, _
Forward:=True) = True
Set oRng = Selection.Range
Target.Range.InsertAfter oRng & vbCr
Loop
End With
End With
Target.Activate
End Sub


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


Dogwoodnc wrote:
[Quoted Text]
> I forgot to mention -- we're using Word 2003, with XP operating
> system.
>
> Thanks!
>
> "Dogwoodnc" wrote:
>
>> I'm trying to create a macro that will:
>> a) Find all words/terms in a doc that are formatted blue
>> b) Copy those words/terms and paste them into a (new) blank document
>>
>> I've been able to do this manually (via Find/ Highlight All
>> Occurrences/ Format(Font)/ Find All/ Copy/ New Doc/ Paste).
>> However, I have not been able to get a macro to contain these
>> commands.
>>
>> Any suggestions??
>>
>> THANKS in advance!


Re: Finding All Words with Specific Format -- via Macro
Dogwoodnc 12/12/2008 12:59:01 PM
THANK YOU! That's exactly what I wanted to do!!!


"Graham Mayor" wrote:

[Quoted Text]
> How about
>
> Sub CopyBlueToOtherDoc()
> Dim Source As Document
> Dim Target As Document
> Dim oRng As Range
> Dim sView As String
> Set Source = ActiveDocument
> sView = ActiveWindow.View.ShowFieldCodes
> Set Target = Documents.Add
> Application.ScreenUpdating = False
> Source.Activate
> With Selection
> .HomeKey Unit:=wdStory
> With .Find
> .ClearFormatting
> .Replacement.ClearFormatting
> .Font.Color = wdColorBlue
> Do While .Execute(findText:="", _
> MatchWildcards:=False, Wrap:=wdFindStop, _
> Forward:=True) = True
> Set oRng = Selection.Range
> Target.Range.InsertAfter oRng & vbCr
> Loop
> End With
> End With
> Target.Activate
> End Sub
>
>
> --
> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
> Graham Mayor - Word MVP
>
> My web site www.gmayor.com
> Word MVP web site http://word.mvps.org
> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>
>
> Dogwoodnc wrote:
> > I forgot to mention -- we're using Word 2003, with XP operating
> > system.
> >
> > Thanks!
> >
> > "Dogwoodnc" wrote:
> >
> >> I'm trying to create a macro that will:
> >> a) Find all words/terms in a doc that are formatted blue
> >> b) Copy those words/terms and paste them into a (new) blank document
> >>
> >> I've been able to do this manually (via Find/ Highlight All
> >> Occurrences/ Format(Font)/ Find All/ Copy/ New Doc/ Paste).
> >> However, I have not been able to get a macro to contain these
> >> commands.
> >>
> >> Any suggestions??
> >>
> >> THANKS in advance!
>
>
>
Re: Finding All Words with Specific Format -- via Macro
"Graham Mayor" <gmayor[ at ]REMOVETHISmvps.org> 12/12/2008 2:02:03 PM
You are welcome :)

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


Dogwoodnc wrote:
[Quoted Text]
> THANK YOU! That's exactly what I wanted to do!!!
>
>
> "Graham Mayor" wrote:
>
>> How about
>>
>> Sub CopyBlueToOtherDoc()
>> Dim Source As Document
>> Dim Target As Document
>> Dim oRng As Range
>> Dim sView As String
>> Set Source = ActiveDocument
>> sView = ActiveWindow.View.ShowFieldCodes
>> Set Target = Documents.Add
>> Application.ScreenUpdating = False
>> Source.Activate
>> With Selection
>> .HomeKey Unit:=wdStory
>> With .Find
>> .ClearFormatting
>> .Replacement.ClearFormatting
>> .Font.Color = wdColorBlue
>> Do While .Execute(findText:="", _
>> MatchWildcards:=False, Wrap:=wdFindStop, _
>> Forward:=True) = True
>> Set oRng = Selection.Range
>> Target.Range.InsertAfter oRng & vbCr
>> Loop
>> End With
>> End With
>> Target.Activate
>> End Sub
>>
>>
>> --
>> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>> Graham Mayor - Word MVP
>>
>> My web site www.gmayor.com
>> Word MVP web site http://word.mvps.org
>> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>>
>>
>> Dogwoodnc wrote:
>>> I forgot to mention -- we're using Word 2003, with XP operating
>>> system.
>>>
>>> Thanks!
>>>
>>> "Dogwoodnc" wrote:
>>>
>>>> I'm trying to create a macro that will:
>>>> a) Find all words/terms in a doc that are formatted blue
>>>> b) Copy those words/terms and paste them into a (new) blank
>>>> document
>>>>
>>>> I've been able to do this manually (via Find/ Highlight All
>>>> Occurrences/ Format(Font)/ Find All/ Copy/ New Doc/ Paste).
>>>> However, I have not been able to get a macro to contain these
>>>> commands.
>>>>
>>>> Any suggestions??
>>>>
>>>> THANKS in advance!


Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net