(e-mail address removed) wrote...
thank you very much! one more thing though, I cannot set the macro
to run when opening the file. There are other users that uses this
file. is there a way to call a particular macro?
The better approach would be to use a different workbook to hold the
macro(s) you need to run on moved/copied files. That macro (those
macros) would include statements like
Dim wb As Workbook, wbn As String
':
On Error Goto CleanUp
Application.EnableEvents = False
':
For Each wbn In some_array_of_filenames
Set wb = Workbooks.Open Filename:=wbn
With wb
'do whatever you need to do here
.Close SaveChanges:=True ' presumably you'd save your changes
End With
Next wbn
':
CleanUp:
Application.EnableEvents = True
Simplest to make this the Open event handler in this extra, server-
side workbook, and open it only after having copied/moved the files in
question.
As for determining the files in question, use xcopy rather than copy,
specifically, something like
del D:\est\ina\tion\filelist.txt
for /F "tokens=3 delims=>" %%a ^
in ('xcopy /s/f S:\our\ce*.xls D:\est\ina\tion\') do ^
echo %a >> D:\est\ina\tion\filelist.txt
then have your server-side workbook read the list of files to be
processed from the text file generated from the xcopy command, which
in the example above is D:\est\ina\tion\filelist.txt . You may or may
not want to use xcopy's /s switch (include subdirectories), but you
*DO* want to use its /f switch. Note also that the circumflexes ^ at
the end of the 2nd and 3rd lines above are MANDATORY as command
continuation characters.