Macro to export table in the same folder as the .mdb file

1992

Registered User.
Local time
Today, 01:56
Joined
Aug 10, 2011
Messages
18
I'm running Access 2010. I have a macro which exports my table "tbl_orders" as an excel file called "orders.xls" (I'm exporting for graphing purposes).

The details are:
ExportWithFormatting
Object Type: Table
Object Name: tbl_orders
Output Format: Excel 1997-2003 .xls
Output File: ???
Auto Start: Yes
Template File:
Encoding:
Output Quality: Screen

In the "output file" field, if I just write "orders.xls" as the location of the file, it gets save to my docs. if I type "\oders.xls", it gets saved to C:\

Is there any way I can get this exported spreadsheet to be stored in the same folder as my access database, no matter where the database is? The reason for this is that I use it on my laptop and on my work PC and lots of other people will be using it if it proves useful, so keeping everything "relative" would make it easier for us to use and transfer without having to change paths etc.

Thanks a lot.
 
I'm running Access 2010. I have a macro which exports my table "tbl_orders" as an excel file called "orders.xls" (I'm exporting for graphing purposes).

The details are:
ExportWithFormatting
Object Type: Table
Object Name: tbl_orders
Output Format: Excel 1997-2003 .xls
Output File: ???
Auto Start: Yes
Template File:
Encoding:
Output Quality: Screen

In the "output file" field, if I just write "orders.xls" as the location of the file, it gets save to my docs. if I type "\oders.xls", it gets saved to C:\

Is there any way I can get this exported spreadsheet to be stored in the same folder as my access database, no matter where the database is? The reason for this is that I use it on my laptop and on my work PC and lots of other people will be using it if it proves useful, so keeping everything "relative" would make it easier for us to use and transfer without having to change paths etc.

Thanks a lot.

Code:
[FONT=Courier New]Dim sCurrentPath as String[/FONT]
[FONT=Courier New]sCurrentPath = CurrentProject.Path & "\"[/FONT]
 
Code:
[FONT=Courier New]Dim sCurrentPath as String[/FONT]
[FONT=Courier New]sCurrentPath = CurrentProject.Path & "\"[/FONT]
Where does this go?
 
Put this in the output box:

=application.currentproject.path & "\Orders.xls"

JR
 

Users who are viewing this thread

Back
Top Bottom