[Webinar] Streamline your web hosting managementRegister Today

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 291
  • Last Modified:

Correct way to kill

The below code works. Now what I now need to do is delete the file after I have transferred the data to Access.
After I execute my DoCmd TransferSpreadsheet statement is this all I need to do to delete the file?

Kill fileName
With Application.FileDialog(msoFileDialogOpen)
    .Title = "Select File"
    .Filters.Add "Excel Files", "*.xls"
    .InitialFileName = "D:\WilliamsSonoma\OB4"
    result = .Show
    fileName = Trim(.SelectedItems(1))
End With

   DoCmd.SetWarnings False
   DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "tblLaborMgmtDataImport", fileName, True, "Sheet1!A:G"
Frank Freese
Frank Freese
1 Solution
Rey Obrero (Capricorn1)Commented:
you just need

Kill fileName    

filename is the complete path to your file
Yes. Is it not working?
Shanmuga SundaramDirector of Software EngineeringCommented:
Kill "Filename with path" will work as capricorn1 suggests. Eg: Kill "C:\test.txt". if not you can also use filesystem object to delete a file.Hope this will help you if you want to delete using FSO.

Frank FreeseAuthor Commented:
again, many thanks. just wanted to be right before being stupid.

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now