Discussion:
TransferSpreadsheet
(too old to reply)
colmkav
2012-05-21 12:11:32 UTC
Permalink
Hi,

I am trying to execute the following code in order to automatically
import an excel file to my Access database

DoCmd.TransferSpreadsheet TransferType:=acImport,
SpreadSheetType:=acSpreadsheetTypeExcel5, TableName:="Newdata", _
Filename:=sExcelFile, HasFieldNames:=True

I get the error msg "The command or action 'TransferSheet Data' ins't
available now."

However, when I try to import the file (sExcelFile) manually I am able
to do so.

Where am I possibly going wrong with the code?

regards
Colm
ralph
2012-05-21 14:58:36 UTC
Permalink
On Mon, 21 May 2012 05:11:32 -0700 (PDT), colmkav
Post by colmkav
Hi,
I am trying to execute the following code in order to automatically
import an excel file to my Access database
DoCmd.TransferSpreadsheet TransferType:=acImport,
SpreadSheetType:=acSpreadsheetTypeExcel5, TableName:="Newdata", _
Filename:=sExcelFile, HasFieldNames:=True
I get the error msg "The command or action 'TransferSheet Data' ins't
available now."
However, when I try to import the file (sExcelFile) manually I am able
to do so.
Where am I possibly going wrong with the code?
This error is most often caused by an implicit reference not being
resolved in the current context. Therefore usually resolved by
providing an more explict reference or method.

Try something like ...
DoCmd.TransferSpreadsheet "Object_of_interest"
or
Object_of_interest.TransferSpreadsheet

-ralph

Loading...