Somethings to look for and do
By you running the agent it takes on you rights and not what signed the agent.
Put an on error trap . Chances are the agent does not have the correct permissions
Put some print statements in the code and see if that appears in the log.nsf
I noticed the agent is accessing plik=path+folder+"\"+plik_nazwa.text(0) Does it have rights to this directory?