I am not sure, maybe....! I don't know the program you are 'controlling', avDocM.Close(.T.) may be a command to close the files, but it may still stay open, and invisible? Does it show in task manager?
>Doesn't the line
>
>>avDocM.Close(.T.)
>
>at the end of code do that?