Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
wmmacro wmmacro is offline
external usenet poster
 
Posts: 2
Default Macro to Make List in Word 2003

I am trying to write a macro that would find any word in a document in
quotation marks, ie, "Data" and then take that word and create a list out of
it and any other word in quotations at the bottom of a document. Could
someone help me write that macro? I am a newbie to writing macros and would
appreciate any help I could get.
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Pesach Shelnitz[_2_] Pesach Shelnitz[_2_] is offline
external usenet poster
 
Posts: 277
Default Macro to Make List in Word 2003

Hi,

The following macro uses a wildcard search on a Range object to find single
words in quotation marks. Note that the search also finds words that contain
an apostrophe. The macro adds each word to a list that it inserts at the end
of the document.

Sub ListWordsInQuotes()
Dim myRange As Range
Dim myString As String

Set myRange = ActiveDocument.Range
myString = ""
With myRange
.start = 0
Do While .Find.Execute(FindText:="^34[A-Za-z']{1,}^34", _
MatchWildcards:=True, _
Wrap:=wdFindStop, Forward:=True) = True
.MoveStart Unit:=wdCharacter, Count:=1
.MoveEnd Unit:=wdCharacter, Count:=-1
myString = myString & .Text & vbCrLf
.Collapse Direction:=wdCollapseEnd
Loop
End With
If myString "" Then
ActiveDocument.Bookmarks("\EndOfDoc").Select
Selection.TypeText vbCrLf & "Words in quotation marks" _
& vbCrLf & myString
Else
MsgBox "No words in quotation marks were found."
End If
Set myRange = Nothing
End Sub

--
Hope this helps,
Pesach Shelnitz


"wmmacro" wrote:

I am trying to write a macro that would find any word in a document in
quotation marks, ie, "Data" and then take that word and create a list out of
it and any other word in quotations at the bottom of a document. Could
someone help me write that macro? I am a newbie to writing macros and would
appreciate any help I could get.

  #3   Report Post  
Posted to microsoft.public.word.docmanagement
wmmacro wmmacro is offline
external usenet poster
 
Posts: 2
Default Macro to Make List in Word 2003

Thanks for your quick reply. I pasted this macro into my VBA and then ran it
in a document that only had a sentence, in which there were several words in
quotes. However, it came back with your message "No words in quotation marks
were found." Do you know why this is? Do I have to modify the macro in
anyway? I'm sorry, I'm totally new to this.

"Pesach Shelnitz" wrote:

Hi,

The following macro uses a wildcard search on a Range object to find single
words in quotation marks. Note that the search also finds words that contain
an apostrophe. The macro adds each word to a list that it inserts at the end
of the document.

Sub ListWordsInQuotes()
Dim myRange As Range
Dim myString As String

Set myRange = ActiveDocument.Range
myString = ""
With myRange
.start = 0
Do While .Find.Execute(FindText:="^34[A-Za-z']{1,}^34", _
MatchWildcards:=True, _
Wrap:=wdFindStop, Forward:=True) = True
.MoveStart Unit:=wdCharacter, Count:=1
.MoveEnd Unit:=wdCharacter, Count:=-1
myString = myString & .Text & vbCrLf
.Collapse Direction:=wdCollapseEnd
Loop
End With
If myString "" Then
ActiveDocument.Bookmarks("\EndOfDoc").Select
Selection.TypeText vbCrLf & "Words in quotation marks" _
& vbCrLf & myString
Else
MsgBox "No words in quotation marks were found."
End If
Set myRange = Nothing
End Sub

--
Hope this helps,
Pesach Shelnitz


"wmmacro" wrote:

I am trying to write a macro that would find any word in a document in
quotation marks, ie, "Data" and then take that word and create a list out of
it and any other word in quotations at the bottom of a document. Could
someone help me write that macro? I am a newbie to writing macros and would
appreciate any help I could get.

  #4   Report Post  
Posted to microsoft.public.word.docmanagement
Peter T. Daniels Peter T. Daniels is offline
external usenet poster
 
Posts: 3,215
Default Macro to Make List in Word 2003

It looks like the macro will only find straight-quotes (^34), not
curly-quotes.

On Aug 6, 2:48*pm, wmmacro wrote:
Thanks for your quick reply. *I pasted this macro into my VBA and then ran it
in a document that only had a sentence, in which there were several words in
quotes. *However, it came back with your message "No words in quotation marks
were found." *Do you know why this is? *Do I have to modify the macro in
anyway? *I'm sorry, I'm totally new to this.



"Pesach Shelnitz" wrote:
Hi,


The following macro uses a wildcard search on a Range object to find single
words in quotation marks. Note that the search also finds words that contain
an apostrophe. The macro adds each word to a list that it inserts at the end
of the document.


Sub ListWordsInQuotes()
* * Dim myRange As Range
* * Dim myString As String


* * Set myRange = ActiveDocument.Range
* * myString = ""
* * With myRange
* * * * .start = 0
* * * * Do While .Find.Execute(FindText:="^34[A-Za-z']{1,}^34", _
* * * * * * * * MatchWildcards:=True, _
* * * * * * * * Wrap:=wdFindStop, Forward:=True) = True
* * * * * * .MoveStart Unit:=wdCharacter, Count:=1
* * * * * * .MoveEnd Unit:=wdCharacter, Count:=-1
* * * * * * myString = myString & .Text & vbCrLf
* * * * * * .Collapse Direction:=wdCollapseEnd
* * * * Loop
* * End With
* * If myString "" Then
* * * * ActiveDocument.Bookmarks("\EndOfDoc").Select
* * * * Selection.TypeText vbCrLf & "Words in quotation marks" _
* * * * & vbCrLf & myString
* * Else
* * * * MsgBox "No words in quotation marks were found."
* * End If
* * Set myRange = Nothing
End Sub


--
Hope this helps,
Pesach Shelnitz


"wmmacro" wrote:


I am trying to write a macro that would find any word in a document in
quotation marks, ie, "Data" and then take that word and create a list out of
it and any other word in quotations at the bottom of a document. *Could
someone help me write that macro? *I am a newbie to writing macros and would
appreciate any help I could get.- Hide quoted text -


- Show quoted text -


  #5   Report Post  
Posted to microsoft.public.word.docmanagement
Greg Maxey[_2_] Greg Maxey[_2_] is offline
external usenet poster
 
Posts: 668
Default Macro to Make List in Word 2003

Peter is correct but offers little help in the way of a solution :-(.

Try:

Sub ListWordsInQuotes()
Dim myRange As Range
Dim myString As String
Set myRange = ActiveDocument.Range
myString = vbCr & "Words in quotation marks." & vbCr
With myRange
Do While
..Find.Execute(FindText:="[^0147^01486^34][A-Za-z']{1,}[^0147^01486^34]", _
MatchWildcards:=True, Wrap:=wdFindStop,
Forward:=True) = True
.MoveStart Unit:=wdCharacter, Count:=1
.MoveEnd Unit:=wdCharacter, Count:=-1
myString = myString & .Text & vbCrLf
.Collapse Direction:=wdCollapseEnd
Loop
End With
If myString vbCr & "Words in quotation marks." & vbCr Then
ActiveDocument.Range.InsertAfter myString
Else
MsgBox "No words in quotation marks were found."
End If
Set myRange = Nothing
End Sub

Note: This code only finds words in quotations marks that are located in
the main text storyrange of the document. Additional code and loops are
required if you are interested in find text in areas such as
headers/footers, textboxes, etc.





--
Greg Maxey - Word MVP

My web site http://gregmaxey.mvps.org
Word MVP web site http://word.mvps.org


"Peter T. Daniels" wrote in message
...
It looks like the macro will only find straight-quotes (^34), not
curly-quotes.

On Aug 6, 2:48 pm, wmmacro wrote:
Thanks for your quick reply. I pasted this macro into my VBA and then ran
it
in a document that only had a sentence, in which there were several words
in
quotes. However, it came back with your message "No words in quotation
marks
were found." Do you know why this is? Do I have to modify the macro in
anyway? I'm sorry, I'm totally new to this.



"Pesach Shelnitz" wrote:
Hi,


The following macro uses a wildcard search on a Range object to find
single
words in quotation marks. Note that the search also finds words that
contain
an apostrophe. The macro adds each word to a list that it inserts at the
end
of the document.


Sub ListWordsInQuotes()
Dim myRange As Range
Dim myString As String


Set myRange = ActiveDocument.Range
myString = ""
With myRange
.start = 0
Do While .Find.Execute(FindText:="^34[A-Za-z']{1,}^34", _
MatchWildcards:=True, _
Wrap:=wdFindStop, Forward:=True) = True
.MoveStart Unit:=wdCharacter, Count:=1
.MoveEnd Unit:=wdCharacter, Count:=-1
myString = myString & .Text & vbCrLf
.Collapse Direction:=wdCollapseEnd
Loop
End With
If myString "" Then
ActiveDocument.Bookmarks("\EndOfDoc").Select
Selection.TypeText vbCrLf & "Words in quotation marks" _
& vbCrLf & myString
Else
MsgBox "No words in quotation marks were found."
End If
Set myRange = Nothing
End Sub


--
Hope this helps,
Pesach Shelnitz


"wmmacro" wrote:


I am trying to write a macro that would find any word in a document in
quotation marks, ie, "Data" and then take that word and create a list
out of
it and any other word in quotations at the bottom of a document. Could
someone help me write that macro? I am a newbie to writing macros and
would
appreciate any help I could get.- Hide quoted text -


- Show quoted text -





  #6   Report Post  
Posted to microsoft.public.word.docmanagement
Peter T. Daniels Peter T. Daniels is offline
external usenet poster
 
Posts: 3,215
Default Macro to Make List in Word 2003

My solution, which I knew Greg would plotz over, would simply be to
replace the curly-quotes with straight-quotes (and re-replace them at
the end, if necessary).

But hey, Greg has a hammer, so everything looks like a nail to him.

On Aug 6, 8:00*pm, "Greg Maxey"
wrote:
Peter is correct but offers little help in the way of a solution :-(.

Try:

Sub ListWordsInQuotes()
Dim myRange As Range
Dim myString As String
Set myRange = ActiveDocument.Range
myString = vbCr & "Words in quotation marks." & vbCr
With myRange
* Do While
.Find.Execute(FindText:="[^0147^01486^34][A-Za-z']{1,}[^0147^01486^34]", _
* * * * * * * * * * * * *MatchWildcards:=True, Wrap:=wdFindStop,
Forward:=True) = True
* * .MoveStart Unit:=wdCharacter, Count:=1
* * .MoveEnd Unit:=wdCharacter, Count:=-1
* * myString = myString & .Text & vbCrLf
* * .Collapse Direction:=wdCollapseEnd
* Loop
End With
If myString vbCr & "Words in quotation marks." & vbCr Then
* ActiveDocument.Range.InsertAfter myString
Else
* MsgBox "No words in quotation marks were found."
End If
Set myRange = Nothing
End Sub

Note: *This code only finds words in quotations marks that are located in
the main text storyrange of the document. *Additional code and loops are
required if you are interested in find text in areas such as
headers/footers, textboxes, etc.

--
Greg Maxey - *Word MVP

My web sitehttp://gregmaxey.mvps.org
Word MVP web sitehttp://word.mvps.org

"Peter T. Daniels" wrote in ...
It looks like the macro will only find straight-quotes (^34), not
curly-quotes.

On Aug 6, 2:48 pm, wmmacro wrote:



Thanks for your quick reply. I pasted this macro into my VBA and then ran
it
in a document that only had a sentence, in which there were several words
in
quotes. However, it came back with your message "No words in quotation
marks
were found." Do you know why this is? Do I have to modify the macro in
anyway? I'm sorry, I'm totally new to this.


"Pesach Shelnitz" wrote:
Hi,


The following macro uses a wildcard search on a Range object to find
single
words in quotation marks. Note that the search also finds words that
contain
an apostrophe. The macro adds each word to a list that it inserts at the
end
of the document.


Sub ListWordsInQuotes()
Dim myRange As Range
Dim myString As String


Set myRange = ActiveDocument.Range
myString = ""
With myRange
.start = 0
Do While .Find.Execute(FindText:="^34[A-Za-z']{1,}^34", _
MatchWildcards:=True, _
Wrap:=wdFindStop, Forward:=True) = True
.MoveStart Unit:=wdCharacter, Count:=1
.MoveEnd Unit:=wdCharacter, Count:=-1
myString = myString & .Text & vbCrLf
.Collapse Direction:=wdCollapseEnd
Loop
End With
If myString "" Then
ActiveDocument.Bookmarks("\EndOfDoc").Select
Selection.TypeText vbCrLf & "Words in quotation marks" _
& vbCrLf & myString
Else
MsgBox "No words in quotation marks were found."
End If
Set myRange = Nothing
End Sub


--
Hope this helps,
Pesach Shelnitz


"wmmacro" wrote:


I am trying to write a macro that would find any word in a document in
quotation marks, ie, "Data" and then take that word and create a list
out of
it and any other word in quotations at the bottom of a document. Could
someone help me write that macro? I am a newbie to writing macros and
would
appreciate any help I could get.-

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
ISO macro to make an index list of defined terms glnz2 Formatting Long Documents 3 January 1st 12 01:12 AM
How do I make a macro available every time I open Word? Dan Microsoft Word Help 1 June 19th 07 06:15 AM
How do I make a list of people from an *.mdb recipients list Vicki Mailmerge 17 May 20th 06 01:44 PM
Word Macro, List Commands is missing rplameri Microsoft Word Help 2 December 4th 05 01:16 AM
How to make list of names & addresses to list of mailing labels? Charles McInnis Microsoft Word Help 1 June 27th 05 02:38 AM


All times are GMT +1. The time now is 08:26 AM.

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

About Us

"It's about Microsoft Word"