
Can't copy file after recent modification
I'm not sure if this is really a VB question or a Windows question, but
please bear with me. (Also pardon the dual-post, but I figured this might
be something only a beginner would mess up, or perhaps only someone with
experience could help with.)
My environment involves original files of type A stored on a server in
directory A.
The originals are modified then saved with " wo" added at the end (e.g.
"sample.doc" becomes "sample wo.doc") in Directory B. At this point they
are type B files.
The related type A file then needs to be moved to the B directory.
This is the code I wrote. It works inconsistently.*
'----------
Sub movefile()
Dim lname$, sname$, fnl%
lname$ = ActiveDocument.Name
fnl% = Len(lname$)
If Right$(lname$, 7) = " wo.doc" Then
sname$ = Left$(lname$, (fnl% - 7))
FileCopy "\\Server\A\" & sname$ & ".doc", "\\Server\B\" & sname$ & ".doc"
Kill "\\Server\A\" & sname$ & ".doc"
Else
MsgBox "Your file must end in ' wo.doc' for this funtion to work."
End If
End Sub
'----------
*If I don't modify the A file before saving it as B, it works fine. Also,
if I modify A, save as B, close B, reopen B, and run the code, it works
fine.