try: ### look if there is an open image strPath = App.ActiveDocument.Name strFile = App.ActiveDocument.Title strDir = strPath.rstrip(strFile) except: ### no document open # MsgBox App.Do( Environment, 'MsgBox', { 'Buttons': App.Constants.MsgButtons.OK, 'Icon': App.Constants.MsgIcons.Stop, 'Text': "You must have an open image. Script will be aborted.", }) return