I need a super duper mail merge macro created. Please help

M

malycom

Is there a way to create a template for a word document to have certain
fields pre-populated with form fields and then create a macro to take the
necessity for a user to have to open Mail Merge wizzard and start locating
the data source etc?

Deeper.....

We run our in house software and we can press a 'Letter' button which
creates a .dbf file which is automatically saved in the root of the users C
drive. If they have created this .dbf file, it means they are going to send
a letter to the person who was on the form they were looking at before
clicking the 'Letter' button.

Now, just assuming that the only fields in the dbf file were
first name
last name
address
I would want the user to open there template document (not saved in the C
drive) which would already have the first name, last name and address form
fields in the correct place of the template.

This is when I would like the user to be able to press a form button or
whatever that will then automatically point the fileds to the corresponding
fields in the .dbf field so that our users do not have to try and use the
Mail Merge wizard. They WILL NOT use the Mail Merge wizard as they are
scared of computers.

I know this may be complex or even impossible, but if it can be done, you
will forever be deemed a hero. If it can't be done, other suggestions are
welcome.

Thanks in advance

Malcolm
 
G

Graham Mayor

Form fields and mail merge are mutually exclusive. However you can insert
MERGE fields in a template and set up an automacro to run the merge. eg

Sub AutoNew()
With ActiveDocument.MailMerge
.MainDocumentType = wdFormLetters
.OpenDataSource name:= _
"C:\Filename.dbf", ConfirmConversions:=False
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute
End With
End Sub

will merge the data source
C:\Filename.dbf
into the current merge document created by your template, to a new document.
If you prefer to send the document to the printer change
wdSendToNewDocument
to
wdSendToPrinter


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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
M

malycom

Thanks Graham

I think this is going to be just what we needed (Fingers crossed).

Many thanks

Malcolm
 
M

malycom

Graham

Noted thanks. As it happens, I am going to create a form that gives the
user the choice of templates to open and I have enough info from you to
achieve this.

Many thanks for your help.

Malcolm

P.S. As I said in my initial question, you will forever be deemed a hero :)
 

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