Can I Use TransferSpreadsheet to export ?

G

Guest

I've set up this VB command,

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9,
"tbl.MasterTestResults", "C:\Data\MasterTestResults.xls", ,
"tblMasterTestResults"

but the compiler is highlighting acExport and saying its an "invalid outside
procedure"

How do I set up to export ?
 
G

Guest

Yes, but I saw two problems:
1. The last argument in your action is not allowed for exports. It is only
for imports so you can identify exactly what data from a workbook you want.
I read somewhere there is a way to trick it, but I don't know what it is.

2. I took the "." out of tblMasterTestResults. I doubt that is your table
name

Try this:
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9,
"tblMasterTestResults", "C:\Data\MasterTestResults.xls"
 
G

Guest

Thanks. I tried

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9,
"tblMasterTestResults", "C:\Data\MasterTestResults.xls"

The names and locations of the table and spreadsheet are correct
But I'm still getting "Invalid outside procedure" on acExport
 
G

Guest

hhhhhhhhmmmmmmmmmmm?????????
I've never seen that. Have you checked your references to be sure you have
Microsoft Excel 9.0 Object Library checked?
 
K

Ken Snell [MVP]

Klatuu said:
Yes, but I saw two problems:
1. The last argument in your action is not allowed for exports. It is
only
for imports so you can identify exactly what data from a workbook you
want.
I read somewhere there is a way to trick it, but I don't know what it is.

Though not documented and Help file says it's not possible, it appears that
you can specify the Range argument for exports. Syntax is exactly the same
as that used for imports.
 
D

david epsom dot com dot au

The debugger can get confused about the exact position of
an error on a line. If you can't see an error, look to the
left. Are you sure that you are inside a procedure?

(david)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top