I have a form with a button that exports a CSV list of addresses for a Mail Merge. How do I access the "Save As" dialog so the user can specify a location to save the file, rather than just arbitrarily putting it somewhere?
That's a big mes of code that I was hoping to avoid. How do I get the environmental variables, like %HOMEPATH% or %USERPROFILE% and set these as a hardcoded location for saving the CSV file to?
Yes, it is a lot of code, however, there is nothing you need to modify to make it work. You only need to paste it into a module in the modules tab of the access window. After that, you call the fGetFileName in your form's code such as on click event. For example, this is a statement I use that calls the function(s) and then extracts a portion of the file name.
MBAFileDate = Right(fGetFileName(), 8) 'Choose any Current file and extract the date extension
This brings up the common file save dialog box and then the user clicks on a file and the information about the file is saved to a variable.
Your second post indicates you want to hard code the values, so not clear whether you want the user to be able to choose the file or to predefine the file.
I'll try putting it in as a module,and see how it goes.
Hard-coding a download location would have been for sending the created CSV to the user's desktop, no matter what their username is. As is,it's going straight to C:\Address.csv
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.