Get address from all letters in a folder...

F

Faye

Hello
I've searched the newsgroups, but can't find anything on this. I hope someone can help me do this
I need to loop through all letters in a folder, extract the delivery address from each, and add it to a list to create an address list of all receipients of these letters. This is a kind of reverse mail merge where a 'data' file (just a tab delimited list in a document) is created from the letters instead of the opposite. I know that there's an activedocument.envelope.address.text property, but none of these letters have an envelope. How does Word extract these 'Inside addresses' for the E&L wizard
Thank you! ( Using Word97)
 
F

Faye

In case anyone wants to use it or comment...
Sub GrabAddresses()
Dim vFile As String
Dim PathToUse As String
Dim vDoc As Document
Dim vAddr As String

PathToUse = "C:\Documed\List Maker\Files\"
On Error Resume Next
vFile = Dir$(PathToUse & "*.doc")
While vFile <> ""
Set vDoc = Documents.Open(PathToUse & vFile)
Selection.Find.ClearFormatting
Selection.Find.Font.Underline = wdUnderlineSingle
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Font.Underline = wdUnderlineNone
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
vDoc.envelope.Insert
vAddr = vDoc.envelope.Address.Text
Documents("List.doc").Activate
Selection.EndKey Unit:=wdStory
Selection.TypeText (vAddr)
Selection.TypeText vbCr
Selection.TypeText Text:="~"
Selection.TypeText vbCr
vDoc.Close SaveChanges:=wdDoNotSaveChanges
vFile = Dir$()
Wend
End Sub

----- Faye wrote: -----

Hello,
I've searched the newsgroups, but can't find anything on this. I hope someone can help me do this.
I need to loop through all letters in a folder, extract the delivery address from each, and add it to a list to create an address list of all receipients of these letters. This is a kind of reverse mail merge where a 'data' file (just a tab delimited list in a document) is created from the letters instead of the opposite. I know that there's an activedocument.envelope.address.text property, but none of these letters have an envelope. How does Word extract these 'Inside addresses' for the E&L wizard?
Thank you! ( Using Word97)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top