This is not a good way of doing things. You should call this function from a
document-level script, or from a menu item that you click after the file has
I am trying to search existing documents without having to modify them, so I thought that a folder-level script might work.
A folder-level script can be used for two things:
- Execute commands relevant to the application as a whole, NOT dependent of
any specific document (e.g. adding new menu items).
- Create functions which should be available to any document or script that
might need them (e.g. formatting a string in a certain way).
What you're trying to do is neither here nor there. If you want to be able
to search existing documents, you can use a folder-level function, but then
you need to call it from somewhere else, like a menu item or a toolbar