try
{
var
doc=app.activeDocument;
alert(doc.name);
}
catch
(e){
alert(e);
alert(
"アクティブになっているドキュメントはありません"
);