I am trying to write some code to import some excel books into a table. The book needs to be heavily edited before it can be imported, and I have accomplished all of that, but I'm having trouble with the line that actually imports the worksheet into my table. Here is what I have:
My problem is with (i think):
The error I get is: "An Expression you entered is the wrong data type for one of the arguements." I'm sure this refers to the wb variable needing to be a path and file name, but I don't want the code to open another book, what it needs is already open.
Can anyone help?!
Code:
Sub gatherdata()
'set variables
Dim xlApp As New Excel.Application
Dim wb As workbook
Dim ws As worksheet
Dim FilePath As String
FilePath = "C:\test.xls"
xlApp.Visible = True
Set wb = xlApp.workbooks.Open(FilePath)
Set ws = wb.ActiveSheet
'Begin altering data
'(code here)
'Data is altered to look exactly like it should in the table
DoCmd.TransferSpreadsheet acImport, 8, _
"tblTemp", wb, True
'Close book
Set ws = Nothing
wb.Close
Set wb = Nothing
xlApp.Quit
End Sub
My problem is with (i think):
Code:
DoCmd.TransferSpreadsheet acImport, 8, _
"tblTemp", wb, True
The error I get is: "An Expression you entered is the wrong data type for one of the arguements." I'm sure this refers to the wb variable needing to be a path and file name, but I don't want the code to open another book, what it needs is already open.
Can anyone help?!