extracting address from a word document and merging them to label

F

Freida

I have a word document with several sections. At the begining of each
section, there is a vendor name and address. I want to creat a label merge
that copies the addresses contained at the beg. of each section onto the
labels. Is this possible?
 
D

Doug Robbins - Word MVP

It is possible to do such a thing using Visual Basic. For a document with
only several sections, it is probably not worth the effort of creating the
necessary macro, unless it is something that you have to do on a regular
basis.

To give any specific information on how to go about it, it would be
necessary for you to provide additional information on how the address
appears at the beginning of each section of the document.

--
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
 
F

Freida

The 1st 4 lines of each section include the vendor name and the address.
This is something that will need to be done on a regular basis, I made need
the macro for this one. At any give time this doc. Can have anywhere from
10 to 40 sections depending on how often the report is ran.
 
D

Doug Robbins - Word MVP

And is each line a separate paragraph ending in a ¶ (when you click on the
Show/Hide button (¶))?

If that is the case, this code should do it:

Dim i As Long, j As Long
Dim source As Document, target As Document
Dim arange As Range, srange As Range
Set source = ActiveDocument
Set target = Documents.Add
With source
For i = 1 To .Sections.Count
For j = 1 To 3
Set srange = .Sections(i).Range
Set arange = srange.Paragraphs(j).Range
arange.End = arange.End - 1
target.Range.InsertAfter arange & vbTab
Next j
Set arange = srange.Paragraphs(4).Range
target.Range.InsertAfter arange
Next i
End With


--
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
 

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