Hello all,
I am trying to run the function of:
Code:
DoCmd.TransferSpreadsheet(acImport,acSpreadsheetTypeExcel12Xml, "ServiceNow", fileName, True, "A1:F12")
but I keep getting the error code of: Compile error: Expected: =. Um, last time I checked I was trying to import data with this thing and it should not be asking for an = sign. Below is the basic of my code and results of my code. The selectFile is a function that opens a file dialog so that I can point the code to the correct file every time. The rangecount seems to work as well.
Code:
Sub SelectFileToImport()fileName = selectFile
Debug.Print fileName
'open excel and read record
Dim myRec As DAO.Recordset
Dim xlapp As Excel.Application
Dim xlwrksht As Excel.worksheet
Set myRec = CurrentDb.OpenRecordset("ServiceNow")
Set xlapp = CreateObject("Excel.application")
Set xlWrkBk = GetObject(fileName)
Set xlwrksht = xlWrkBk.Worksheets(1)
rangecount = xlwrksht.Cells(xlwrksht.Rows.Count, 1).End(xlUp).Row
DoCmd.TransferSpreadsheet(acImport,acSpreadsheetTypeExcel12Xml, "ServiceNow", fileName, True, "A1:F11")