Export Location Using Access Macro
I have an interesting question. I have an access database and there is a macro that exports certain queries to excel. That is working fine. 开发者_如何学GoHowever, this database is saved on a shared folder of a local network. If I wanted the macro to export the database to the documents folder or desktop folder of the user, how would I do this?
Also, kind of a side note - is it possible to attach some sort of vba code to open the exported document in excel as well?
You can use the environ function to get this kind of information. For example the users desktop can be found by calling this bit of code
Environ("userprofile") & "\Desktop"
For opening the file after you could use this bit of code that opens up a file using the default application for that extension
Application.FollowHyperlink “C:\Your_excel_sheet.xls”
That should set you in the right direction
精彩评论