The information in this article applies to:
SUMMARY
Advanced: Requires expert coding, interoperability, and multiuser skills.
MORE INFORMATION
Microsoft Excel offers some functions that are not available in Microsoft
Access, for example, statistical functions. However, you can access these
functions from within Microsoft Access by using Automation if you first set
a reference to the Microsoft Excel object library.
The following two sample subroutines use Microsoft Excel statistical functions. NOTE: Microsoft Excel does not automatically close after it has been opened by using Automation. The following functions use the Quit method to close Microsoft Excel. For more information about quitting Microsoft Excel, please see the following article in the Microsoft Knowledge Base: Q145770 ACC: Automation Does Not Close Microsoft Excel Example 1The following function uses Automation to call the Microsoft Excel Median() function. Half of the set of numbers fall below and half above the median.
The function displays 6.5 in a message box.
If you are using Microsoft Access 97 with Microsoft Excel 97, you can simplify the code by calling the Microsoft Excel reference directly:
NOTE: When you use this syntax, Microsoft Excel 97 remains in memory until
you reset your code or close your database. Note, too, that although this
syntax works with Microsoft Excel 7.0, Microsoft Excel 7.0 remains in
memory after you reset your code or close your database, and even after
you quit Microsoft Access. To conserve system resources, do not use this
syntax with Microsoft Excel 7.0.
Example 2The following function uses Automation to call the Microsoft Excel ChiInv() function, which returns the inverse or the one-tailed probability of the Chi-Squared distribution:
This function displays 18.3070290368475 in a message box.
If you are using Microsoft Access 97 with Microsoft Excel 97, you can simplify the code by calling the Microsoft Excel reference directly:
Refer to the NOTE in Example 1 for information about the ramifications of
using this syntax.
Microsoft Excel also uses add-ins. These are programs that include custom functions and commands. If you need to use a function included in an add-in program, you must first open the add-in. The following is an example of using the LCM (Least Common Multiple) function:
This function displays 10 in a message box.
REFERENCES
For more information about using Automation, search for Automation, and
then Automation with Microsoft Access using the Microsoft Access 97 Help
Index.
Additional query words:
Keywords : |
Last Reviewed: November 10, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |