Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Importing an empty excel table into Access 1

Status
Not open for further replies.

Hanss

Technical User
Feb 15, 2001
85
CH
The following code imports “temp.xls” into an access table “import”. However it fails if temp.xls does not contain any data:

ResultCode = Worksheet.SaveAs("C:\temp.xls", 4, 0)
*** see below
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "import", "C:\temp.xls", False, ""

*** Here I would like to add code which:

1) checks if temp.xls is 3584 bytes in which case it has no data, and
2) then copies over temp.xls with temp2.xls. Temp2.xls has zeros and the import then works.

Something like this:

if c:\temp.xls = 3584 bytes, copy c:\temp2 c:\temp.xls

Any help would be greatly appreciated!

Hans
Zurich
 
Code:
If [b]LEN([/b]"c:\temp.xls"[b])[/b] = 3584 Then
   [b]FileCopy[/b] "C:\Temp2.xls" "C:\Temp.xls"
End If

Hope this helps,
CMP

Funny thing about being unemployed, weekends don't mean quite so much, just means you get to hang out with your working friends. Primus
 
Thank you so much for your help! Everything works great.

Hanss
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top