[FONT="]Hi…I’m trying to embed a .csv file to an excel sheet and then delete the source file using Windows 10 and Excel 2016. My code embeds the sourcefile to the worksheet ok but when it tries to delete the original .csv file I get a “Run-time error ’70’: Permission denied message. I’ve tried the same code using a .txt file instead and it seems to run fine. Is there any way to release the .csv file from excel so it can be deleted without having to convert my file to a .txt?[/FONT]
[FONT="]Public Sub EmbedFile()[/FONT]
[FONT="] Dim oFile As OLEObject[/FONT]
[FONT="] Dim fPath As String[/FONT]
[FONT="] fPath = “C:TempTest.csv”[/FONT]
[FONT="] Set oFile = ActiveSheet.OLEObjects.Add(Filename:=fPath, Link:=False, DisplayAsIcon:=True, IconIndex:=0, IconLabel:=fPath)[/FONT]
[FONT="] Set oFile = Nothing[/FONT]
[FONT="] Kill fPath[/FONT]
[FONT="]End Sub[/FONT]
[FONT="]Public Sub EmbedFile()[/FONT]
[FONT="] Dim oFile As OLEObject[/FONT]
[FONT="] Dim fPath As String[/FONT]
[FONT="] fPath = “C:TempTest.csv”[/FONT]
[FONT="] Set oFile = ActiveSheet.OLEObjects.Add(Filename:=fPath, Link:=False, DisplayAsIcon:=True, IconIndex:=0, IconLabel:=fPath)[/FONT]
[FONT="] Set oFile = Nothing[/FONT]
[FONT="] Kill fPath[/FONT]
[FONT="]End Sub[/FONT]