I want to do a WORD mailmerge linked to a Excel database.
Also I want to make a self defined function in Vba-editor module:
A simple example:
Function test (number1, number2)
test = number1 * number2
End Function
(number1 and number2 refer to fields in the Excel database)
How to make this function work in the document?
Doug Robbins - Word MVP - 15 Apr 2004 03:10 GMT
You can't.
Use another column in the database to contain the product of the number1 and
number2.
Why use Word as a calculator when you have a spreadsheet?

Signature
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
> I want to do a WORD mailmerge linked to a Excel database.
> Also I want to make a self defined function in Vba-editor module:
[quoted text clipped - 12 lines]
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.657 / Virus Database: 422 - Release Date: 13-4-2004
Peter Jamieson - 15 Apr 2004 10:40 GMT
In addition to Doug's response which describes the simplest solution, all
other things being equal,
a. if you are using Word 2002 or later you can use Word's Mailmerge events
to fire a VBA routine immediately before each record in the data source is
merged. You can use the event to insert the value you want in a number of
ways, e.g. by setting the value of a Document Variable and using a {
DOCVARIABLE } field in the document.
b. you may be able to "add columns" to your data source using an SQL SELECT
statement in an OpenDataSource routine (if you are getting your data from
Excel via ODBC or OLEDB)
c. you can use a DATABASE field in your main document to return the results
of Jet SQL functions, but you typically have to have an additional file to
do it.

Signature
Peter Jamieson - Word MVP
Word MVP web site http://word.mvps.org/
> I want to do a WORD mailmerge linked to a Excel database.
> Also I want to make a self defined function in Vba-editor module:
[quoted text clipped - 12 lines]
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.657 / Virus Database: 422 - Release Date: 13-4-2004