Link to home
Start Free TrialLog in
Avatar of jfer0x01
jfer0x01Flag for United States of America

asked on

MS Access VBA - User sets output directory for Excel Exports

Hi,

I have many Queries that Excel Exports to an .xls, at a determined directory, like so,

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel7, "ASP", "C:\Databases\Access to Excel.xls", True

This executes when a user pushes a button on a form.

Now, i need to substitute my  Path,  "C:\Databases\Access to Excel.xls", with a Variable

let say "Dim OutPutPath", And let the user select the output directory, via windows explorer,

so it copies the path information the user selected to my "OutPutPath" variable, since I need to export over 30 queries to Excel this way,and their is no way we can select the same directory in real time, 30 times!

Thanks!
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Option 1: User uses Windows Explorer and navigates the path, copies the path, and pastes the path into an unbound textbox on the same form as the export button. You can then do something like this near the top of your sub
OutPutPath = txtCopiedPath <-- the name of the unbound textbox
Option 2: Use the CommonDialog Class under ActiveX Controls
Option 3: Use a tedious combination of comboboxes and listboxes and events - not recommended
Lee