excel vba - Failure to reliably overwrite file from VBA -


i have vba program should delete , overwrite file, same name. code sample below. worked fine until maybe several months ago, when overwrite started behaving strangely despite no apparent change anywhere. @ times, file not overwritten @ all. tried deleting file manually before doing write vba, didn't work, instead looked previous version in recycle bin being restored, rather overwriting new version.

when manually delete file in target folder, , delete previous revs recycle bin, write works fine.

posting following lot of googling , other searching, nothing describes specific problem. suggestions on what's happening here / how fix?

excel 2013 under win10. nothing unusual platform, excel setup or file being written, plenty of disk space available.

fname = "c:\datfolder\incrdat.bin" kill fname   ' remove previous file fnum = freefile open fname binary access write #fnum  .... write  close #fnum 

edit 14 may, following many trials.

omg how can difficult??? :-/. i've put error checks on file ops, none occur. i've added 1-sec wait between kill , file create. happens every time, following delete , rewrite, there file there again, it's previous file old timestamp. ie. somehow file has been deleted put previously.

when step through code in debug, works fine.

many suggestions, none of them have worked. i'm giving , redoing whole damn thing in c++, know that'll work.

one more thing, unfortunately suggestions rewrite different file name, or different folder, can't used unfortunately.


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -