Results 1 to 3 of 3
  1. #1
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    Import Code Not working (2002)

    Hi!

    I'm using the following code to import any excel files that reside in a folder. I copied from another database where it is working fine and changed the file names, locations etc. It doesn't pull anything in and I'm not getting an error message. I've double checked and triple checked the spellings of the locations and files and all seems correct. Is there something missing in the code?

    Dim strFolder As String
    Dim strFile As String


    strFolder = "C:SSISSAM FilesBilling Manager FilesSales Item Report"
    strFile = Dir(strFolder & "*.xls")
    Do While strFile <> ""
    DoCmd.TransferSpreadsheet _
    TransferType:=acImport, _
    SpreadsheetType:=acSpreadsheetTypeExcel97, _
    TableName:="tblSalesItemReport", _
    FileName:=strFolder & strFile, _
    HasFieldNames:=True, _
    Range:="sales0001a"
    strFile = Dir
    Loop

    Thanks,
    Leesha

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Import Code Not working (2002)

    There's no backslash at the end of the path, so there is nothing to separate the path from the filename. Change the first line to
    <code>
    strFolder = "C:SSISSAM FilesBilling Manager FilesSales Item Report"</code>

  3. #3
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Import Code Not working (2002)

    Thanks Hans! That did the trick.

    Leesha

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •