Forum

Read-Only Program I...
 
Notifications
Clear all

Read-Only Program Inputs InUseNO or InUSeYES in folder error 53

6 Posts
2 Users
0 Reactions
89 Views
(@stevenbehr1)
Posts: 92
Estimable Member
Topic starter
 

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

 
Posted : 21/01/2021 12:24 am
(@debaser)
Posts: 838
Member Moderator
 

You're still missing a backslash on the end of your FileControllerFolder constant.

 
Posted : 21/01/2021 7:07 am
(@stevenbehr1)
Posts: 92
Estimable Member
Topic starter
 

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

 
Posted : 21/01/2021 7:28 am
(@debaser)
Posts: 838
Member Moderator
 

It's Velouria, not Velouris. 😉

 

Given the name of the sample file you posted, do you have a folder called:

 

H:PROJECT-OPSMultipleUsersIssueFilesInUseTest-1

 
Posted : 22/01/2021 4:45 am
(@stevenbehr1)
Posts: 92
Estimable Member
Topic starter
 

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

 
Posted : 22/01/2021 4:03 pm
(@debaser)
Posts: 838
Member Moderator
 

You should remove the bold line completely. The path is supplied when you call that routine - the routine should not change it.

 
Posted : 23/01/2021 6:03 am
Share: