this happens eariler time, but it gets recovered after putting the following line
this time that command also not works.
Have you tried putting in a delay (in VB: 'sleep' command)?
Maybe without alert, the script jumps too soon into the following statement, while other processing/file saving/whatever is still finishing?
That should be:
As for the rest of your question, there's no way to even begin to guess without seeing the code of your function.
function is not a problem, the following things did the probls, i found it