| the Manx Man's MS Access Pages to subscribe - click here Sending Data to Excel - Part 1 (023) A recent project for a client required a variety of "reports" that could be easily sent to a wide variety of people. Since most of the employees did not have MS Access on their computers, we had to find an easy way of getting the data to them. A report viewer is available, however, this option was quickly dismissed. Since almost every employee has MS Excel on their computers, I suggested that we get the Access program to create output in Excel format. The Excel workbook could then be e-mailed to the appropriate people and they could view and/or print the "reports". The following is some sample code to open and populate an Excel workbook.
As usual, I am not suggesting that I have discovered the best code, but it works. Let me
know if you have found a "slicker" way to do this. Part 2 of this article will examine how to shade, draw borders around data, and do things like auto column width sizing. NOTE: This code will only work if you have Excel references turned on. The References section is found under the Tools menu in the VBA editor. p.s. The above code was based on VBA from an Access 2000 project
that uses DAO references. The code was modified for use in this article and was not tested
in Access. For example, I removed all error checking portions of the code. This code
should also work in Access 97, however, the author makes no warranties of such. If you
have trouble with the code, e-mail the Manxman (see link below) with your questions.
|
tip # 023 || previous tip || next tip