Hi,
I'm using the code below to import data into a DB. The spreadsheet originally came with only on tab named "Data". Now the spreadsheet comes with 3 tabs and the "Data" tab is no longer the first tab in the spreadsheet. I took a shot a entering the name of the sheet in the code but it returns an error that says that the object "data" can't be found. I'm not sure what I am missing.
Thanks,
Leesha
Dim strFolder As String
Dim strFile As String
' Fixed folder path
strFolder = "C:\StoreID\Import\"
' Find filename
strFile = Dir(strFolder & "*.xlsx")
Do While strFile <> ""
If strFile = "" Then
MsgBox "No .xlsx file in folder!", vbExclamation
Exit Sub
End If
' Import VDC weekly sales spreadsheet
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12Xml, _
"tblImportTemp-VDC", strFolder & strFile, True, "Data"
strFile = Dir
Loop
Naming a tab on an imported spreadsheet
-
- BronzeLounger
- Posts: 1495
- Joined: 05 Feb 2010, 22:25
-
- Administrator
- Posts: 78647
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Naming a tab on an imported spreadsheet
Add an exclamation mark after the sheet name: use "Data!" instead of "Data"
Best wishes,
Hans
Hans
-
- BronzeLounger
- Posts: 1495
- Joined: 05 Feb 2010, 22:25
Re: Naming a tab on an imported spreadsheet
Thanks Hans! I appreciate you and your help,
Leesha
Leesha