I am digging through tons of code to figure out what the problem is so bear with me.
I have a button that when clicked opens a specific excel spreadsheet. What the user is "supposed" to do is modify the worksheet then save it and click a button to attach it back into the Notes form. So far in the 2 years that this program has been in production that is what the users have been doing.
I turned it over to testing to make sure some minor changes didn't affect the program, and testing found a problem that I don't know how to fix. If you click on the button to modify a worksheet and it opens the worksheet, then click on the modify button again before making changes and reattaching, the path/file access error happens.
I have run it through the debugger and this is the code where it hangs up (Kill WorkDir & "\" & AName )
AName = the correct excel file name and fileName$ contains the same file name. WorkDir is C:\temp\.
Anyone have any clues what I can do to cirumvent the user from modifying the worksheet if they already have it open?
Thanks and sorry for the confusion,
Private Function RmvExstFile ( WorkDir As String, AName As String) As Integer
'// Checks for AName in path directory if exists kill it before launch an attachment
'// Called by : Modify Method
'// Calls : None
fileName$ = Dir$(WorkDir, 0)
Do While fileName$ <> ""
fileName$ = Dir$()
If fileName$ = AName Then
Kill WorkDir & "\" & AName
' Msgbox "killed the file :" & tmpPath & "\" & AName
RmvExstFile = 1