I am not able to save the data in existing excel file while it already open and getting message like
“The process cannot access the file ‘D:\Download\TableName.xlsx’ because it is being used by another process.”
Could you please provide some guidanace.
I want to close the file and save again
Hi Girish,
Someone is locking a file, you’ll need to find out who that is.
For instance, do you have automatic scanning from some antivirus software that is going through your downloads?
Or do you perhaps have a stream (like a FileStream
) for that file that’s not being disposed?
Regards,
Mario
' Save the Excel file
Dim saveFileDialog As New SaveFileDialog With {
.FileName = mName + "_" + DateTime.Now.ToString("yyyyMMdd_HHmmss"),
.Filter = "Excel files (*.xlsx)|*.xlsx",
.FilterIndex = 1,
.RestoreDirectory = True
}
If saveFileDialog.ShowDialog() = DialogResult.OK Then
ef.Save(saveFileDialog.FileName)
Else
Exit Sub
End If
This is my code, while trying to save the exting file which is opened. Please provide some suggesstion. Just i am thing, can we closed that file and write though code.
Hi Girish,
Do you mean your file is open in Microsoft Excel?
I’m afraid that Excel applications will lock the files, you cannot save on that path.
You’ll need to close the file to save on that path.
Regards,
Mario