Joe,
it works a bit differently.
You have to tell the macro the path and file name as a string.
This can be done quite easily using vba code, but not with a macro.
This is one of the long list of limitations of macros.
The vba code is like this:
-----------------------------------
Private Sub cmdExport_Click()
Dim strFileAndPath as String
strFileAndPath = Me!report-address
DoCmd.TransferSpreadsheet acExport, _
acSpreadsheetTypeExcel9, "TableNameOrQueryName", _
strFileAndPath
End Sub
-------------------------------------
Note:
Replace TableNameOrQueryName with the name of the table or query you want to
export.
You would put the button called cmdExport on the form called frmReports.
Put the code on the On Click event for that button.
When the user clicks the button, the table or query will be exported to the
workbook.
For other ways to export reports using macros, have a look at the Northwind
database.
In the database window go to Help | Sample Databases
Jeanette Cunningham -- Melbourne Victoria Australia
Joe said:
Hello,
I'm trying to import an excel file using a macro and a field on a form. I
would like for the macro to reference a field in a form to capture the
path
of the spreadsheet.
This is what I entered under the File Name argument:
=[Forms]![frmReports]![report_address]
Is this possible?