Solving Run Time error 3011 with DoCmd.TransferSpreadsheet
Can anyone see what is causing the run time error in my code? I realize it may be difficult without having the spreadsheet, but I am confident the naming is consistent between my code and the spreadsheet. I have tried multiple files and locations, but I keep getting the error. When I hover my arrow over MyRange, it says empty. Thanks!
Function ImportExcelFile()Dim MyDir As StringDim MyFile As StringDim MyYear As StringDim MyMonth As StringDim MyDay As StringDim MyDate As StringDim FileToGet As StringDim shtName As StringMyDir = "//AvailableSummaries/"MyYear = Format(Date, "yyyy")MyMonth = Format(Date, "mm")MyDay = Format(Date, "dd")MyDate = MyYear & " " & MyMonth & "-" & MyDayMyFile = MyDate & " Contractor Available Stock" & ".xls"shtName = "'Contractor Available Inventory'!"MyRange = "A1:D10000"FileToGet = MyDir & MyFileDoCmd.TransferSpreadsheet acImport, 8, "tblContractorAvailableInventory", FileToGet, True, shtName & MyRangeEnd Function
DoCmd.TransferSpreadsheet acImport, 8, "tblContractorAvailableInv