Afternoon,
I have a program where if the file opens itshould indicate in a folder InUseYES.txt using the code.
FileControllerFolder & FileControlSubfolder
If "InUseYes.txt" then Thisworkbook.Close dont Save.
However, even though I created the folders H:PROJECT-OPSMultipleUsersIssueFilesInUse and have a txt file InUseNO_.txt the error comes up Runtime error 53 File Not Found????
The offending error is below
Name FileControlFolder & FileControlSubFolder & _
"InUse_NO.txt" As FileControlFolder & FileControlSubFolder & "InUse_YES.txt"
Does excel see the " . I have tried many other ways to see the file to avail.
Can anyone help me on this code
I attach the file
Thanks
You're still missing a backslash on the end of your FileControllerFolder constant.
Thanks Velouris,
Done that but the error still remains.
Is there any other way of writing to txt file from filecontrolsubfolder " InUseYES.
Is this " correct because it's not seeing this path????
Steve
It's Velouria, not Velouris. 😉
Given the name of the sample file you posted, do you have a folder called:
H:PROJECT-OPSMultipleUsersIssueFilesInUseTest-1
Yes Sorry Velouria ...Stupid spell checker!
Yes I do have H:PROJECT-OPSMultipleUsersIssueFilesInUseTest
It looks as though I found how this code works
1. I needed to put the file Test in the FilesInUse Folder in order to see this file to work
2. InUse_YES now works and subsequently InUse_NO when I close
HOWEVER!!!!.
The TextFile_Create (FileControlFolder & FileControlSubFolder & "" & Environ("UserName") & ".txt") - Does not input username but it does input MyFile in the test folder.
Which is :
Sub TextFile_Create(FilePath As String)
'PURPOSE: Create A New Text File
'Adapted from: www.TheSpreadsheetGuru.com
Dim TextFile As Integer
'What is the file path and name for the new text file?
FilePath = "H:PROJECT-OPSMultipleUsersIssueFilesInUseTestMyFile.txt"
'Determine the next file number available for use by the FileOpen function
TextFile = FreeFile
'Open the text file
Open FilePath For Output As TextFile
'Save & Close Text File
Close TextFile
End Sub
Thanks
Steve
You should remove the bold line completely. The path is supplied when you call that routine - the routine should not change it.