E
Erick C
Good morning everybody -
I am having a problem with a database that I am working on. I have a
file that is created in another database, and I need to import a
specific worksheet in this file. I was hoping that I could figure out
how to get it to work by myself but I have had no luck.
I tried adding the worksheet name into the TransferSpreadsheet command
but I do not think that I did it right.
Can someone help please? The code worked fine when I did not have
multiple tabs in the file, but now that there are multiple worksheets
involved it errors out. My code is below:
Worksheet name that I need to import: Cycle_Count_Overview
Dim strPathFile As String
Dim strTable As String, strBrowseMsg As String
Dim strFilter As String
Dim blnHasFieldNames As Boolean
blnHasFieldNames = True
strBrowseMsg = " Please select the Shrink Analysis Data file to
import…"
strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.xls)",
"*.xls")
strPathFile = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=False, _
DialogTitle:=strBrowseMsg, _
Flags:=ahtOFN_HIDEREADONLY)
If strPathFile = "" Then
MsgBox "No file was selected.", vbOK, "No Selection"
Exit Sub
End If
strTable = "Shrink Analysis Data Table"
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, _
strTable, strPathFile, blnHasFieldNames
MsgBox "Shrink Analysis Data Import Complete.", vbOK, "Status"
Exit Sub
I am having a problem with a database that I am working on. I have a
file that is created in another database, and I need to import a
specific worksheet in this file. I was hoping that I could figure out
how to get it to work by myself but I have had no luck.
I tried adding the worksheet name into the TransferSpreadsheet command
but I do not think that I did it right.
Can someone help please? The code worked fine when I did not have
multiple tabs in the file, but now that there are multiple worksheets
involved it errors out. My code is below:
Worksheet name that I need to import: Cycle_Count_Overview
Dim strPathFile As String
Dim strTable As String, strBrowseMsg As String
Dim strFilter As String
Dim blnHasFieldNames As Boolean
blnHasFieldNames = True
strBrowseMsg = " Please select the Shrink Analysis Data file to
import…"
strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.xls)",
"*.xls")
strPathFile = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=False, _
DialogTitle:=strBrowseMsg, _
Flags:=ahtOFN_HIDEREADONLY)
If strPathFile = "" Then
MsgBox "No file was selected.", vbOK, "No Selection"
Exit Sub
End If
strTable = "Shrink Analysis Data Table"
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, _
strTable, strPathFile, blnHasFieldNames
MsgBox "Shrink Analysis Data Import Complete.", vbOK, "Status"
Exit Sub