| DatabaseLessons.com |
'Serving the Microsoft® Access |
|
|
Opening a Word or Excel File From a ButtonI see this question OFTEN. You have a form and you want to open a specific Word or Excel file by just clicking on a button. Maybe the file name is always the same, maybe it comes from a list, maybe even a file open dialogue box. (article continues after sponsor spot) Type 1 - Let's do the easy one first.
Type 2 - How to handle variable file names Let's say you have a list box or a text box where the user chooses a name or types one in. Here is how to handle this one.
The first example is still "hardcoded" whereas the second example
gets the file name from a listbox on the form. You could also have
the folder name hard coded and just have the file name inputed. Further Suggestions For the last example, with the list box, you need some error handling. For example, what if the user clisks on the button without choosing anything from the list. The ideal in many cases is to have an official windows file open dialogue box. That is beyond the scope of this "tip". If you want it badly, visit google.com and do some searching. The answer is in there somewhere. 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. Happy Coding |
|
|
© 2006, 2007, 2008 Richard W. Killey. All Rights Reserved. |