No .xlsx file in folder! Error

Leesha
BronzeLounger
Posts: 1488
Joined: 05 Feb 2010, 22:25

No .xlsx file in folder! Error

Post by Leesha »

Hi,
I am getting an error while importing an .xlsx file using the code below. I have used this code without issue in the past for other tables. I made sure to copy the path from file manager to be sure I had it correct.

Interestingly, a user was getting this error for a different file last month, with code that had never been an issue. I could not find anything wrong and it imported on other computers without issue. Not sure what is going on. I've also attached the file I'm trying to import just in case there is anything wrong with the file. What am I missing?

Thanks,
Alicia

Code: Select all

    Dim strFolder As String
    Dim strFile As String
    ' Fixed folder path
    strFolder = "C:\Walmart\Import-CDS\VDC-RentAndRoyaltySales"
    ' Find filename
    strFile = Dir(strFolder & "*.xlsx")
    
    If strFile = "" Then
        MsgBox "No .xlsx file in folder!", vbExclamation
        Exit Sub
    End If
    ' Import VDC spreadsheet
    DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12Xml, _
        "tblImportTemp-VDCRentRoyaltySales", strFolder & strFile, True
You do not have the required permissions to view the files attached to this post.

User avatar
HansV
Administrator
Posts: 78512
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: No .xlsx file in folder! Error

Post by HansV »

There should be a backlash at the end of the path:

Code: Select all

    strFolder = "C:\Walmart\Import-CDS\VDC-RentAndRoyaltySales\"
Best wishes,
Hans

Leesha
BronzeLounger
Posts: 1488
Joined: 05 Feb 2010, 22:25

Re: No .xlsx file in folder! Error

Post by Leesha »

Thanks so much Hans!