Question : Automating Word Docs

I have a word document which I need to recreate regularly.

I would normally just recreate a crystal report and enter the data from the database directly into the report. The problem here is that the base document is 20 pages long and I only need to enter like 10 items!

What im looking for is some way to update these fields automatically from vb, I can create a key field and search for it and update it from vb (im sure this is possible conceptually but I dont know how to do it) but I am sure there must be a more elegant way to perform this task?

I woudl be keen to hear ideas here!

thanks!

Answer : Automating Word Docs

The following document has a macro fredamddoris that provides the basis of a loop to update your master document.  WHen run it updates the bookmarks THAT MUST PRE-EXIST in the document.

You would need to edit the updated text to reflect something of your choice but the mechanism should work as in the attached.

Chris
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
Sub fredanddoris()
Dim rng As Range
Dim bm As Variant

    For Each bm In Array("fred", "doris")
        Set rng = ThisDocument.Bookmarks(bm).Range
        rng.Text = " <" & UCase(bm) & "> "
        ThisDocument.Bookmarks.Add _
            Name:=bm, _
            Range:=rng
    Next

End Sub
 
example
 
Random Solutions  
 
programming4us programming4us