| DatabaseLessons.com |
'Serving the Microsoft® Access |
|
|
Sending MS Access Data to Excel - Part 1Access and Excel work very well together. Sending Access Data to Excel is quite easy to do, from a simple export to a more complex process requiring VBA. I have written a number of articles to show you methods that I use. (article continues after sponsor spot) My use of these VBA techniques all started when 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. An Access report viewer is available (see this article), however, this option was quickly dismissed. Since almost every employee had 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". A template was created, with the page designed to fit nicely on paper output, and with appropriate Titles and shaded column headers already designed. Columns intended for numbers were also formatted so that the correct numeric format was used. The following is some sample code from that project. It is designed to open and populate the Excel template 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. NOTE: All the VBA code segments on the Database Lessons site assume that you have DAO references active. If you are not sure what this means, and you are using Microsoft Access 2000 or higher, click here. Also, 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. See the above mentioned article on DAO for more details on the References menu.
When the program reaches the end of the above code, you will be looking at the finished spreadsheet on your monitor. You can now make any minor modifications to it before printing it, saving it to disk, and then e-mailing it as an attachment. Part 2 of this series on Sending Access Data to Excel will examine how to shade, draw borders around data, and do things like auto column width sizing. Further Suggestions: To make sure that you find out whenever we are adding more tips, subscribe to our newsletter. Just click the Subscribe button to the left to start the process. Entire series ...
|
|
|
© 2006, 2007, 2008 Richard W. Killey. All Rights Reserved. |