I know I've done this before, but for the life of me, I cannot seem to remember what character or series of characters I need.
I am running this code:
Which I got from a forum thread over at experts exchange, and trimmed a little bit out, editing variable names a tiny bit as well.
My issue is this: when running it as listed, it will use the NAME for each worksheet, but only actually import the first worksheet in the file. I need it to import a series of worksheets, and of course match the actual sheet to the name.
What I've tried so far are these sort of things:
And
And I attempted to include single quotes for the worksheet name in at least one instance.
When I try any of those variations, I keep getting the error similar to this: "The Microsoft Jet Engine cannot find the file [YourFileName]"
Any suggestions? I know it's just got to be something VERY simple that I just cannot rake up into my current memory!
--
"If to err is human, then I must be some kind of human!" -Me
I am running this code:
Code:
Option Compare Database
Option Explicit
Private Sub ImportTables()
Dim objXl As Object
Dim ws As Object
Dim strWSname As String
Dim i As Integer
Dim sFile As String
Dim sTable As String
sFile = "C:\FDCPACases2008JanThroughApril.xls"
sTable = "My Table"
Set objXl = CreateObject("Excel.Application")
objXl.Workbooks.Open sFile, , True
With objXl
For i = 3 To .Worksheets.Count
strWSname = .Worksheets(i).Name
Set ws = .ActiveWorkbook.Worksheets(i)
[highlight]DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, strWSname, _
sFile, True[/highlight]
Next i
End With
Set objXl = Nothing
End Sub
My issue is this: when running it as listed, it will use the NAME for each worksheet, but only actually import the first worksheet in the file. I need it to import a series of worksheets, and of course match the actual sheet to the name.
What I've tried so far are these sort of things:
Code:
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, strWSname, _
sFile & "#" & strWSname, True
Code:
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, strWSname, _
sFile & "!" & Worksheets(i), True
And I attempted to include single quotes for the worksheet name in at least one instance.
When I try any of those variations, I keep getting the error similar to this: "The Microsoft Jet Engine cannot find the file [YourFileName]"
Any suggestions? I know it's just got to be something VERY simple that I just cannot rake up into my current memory!
--
"If to err is human, then I must be some kind of human!" -Me