PDA

View Full Version : Close Open Text File - No Save Prompts



dj44
11-29-2017, 04:15 AM
Good Morning,


how may i close an open text file on my desktop






Sub Close_File()


Dim FilePath As String

'File Path of Text File

FilePath = "C:\Users\DJ\Desktop\LA122.txt"


'FilePath.Close

Close #1

End Sub



I dont need to open it - I just want to close the already open file without any prompts or anything to save

mdmackillop
11-29-2017, 05:10 AM
Assuming it is open in the same instance of Excel

FilePath = "LA122.txt"
Workbooks(FilePath).Close False

mdmackillop
11-29-2017, 05:29 AM
... otherwise https://social.msdn.microsoft.com/Forums/office/en-US/d8ea7f9d-fa9a-45ae-a514-c16062481090/how-to-close-an-external-application-notepad?forum=accessdev

dj44
11-29-2017, 05:56 AM
Hello M,

excel created the file initially.

now later i just want to close it - because i dont want it anymore

ok let me do some investiagtion

Spkumar
12-12-2017, 06:15 AM
NOT WORK THIS CODE,......................