Part of a script we have lists the saved find and change queries in a list box and allows the user to select a bunch of them to run. My issue is trapping "errors" when loading.
When you select a find and change query manually on the Find dialog InD may display the message "This query refers to formatting elements not found in this document. Continue anyway?" If you click "Yes" it loads the query but may not, for instance, have a particular style assigned. In the scripting (Win 7, InD CS6, VBA) there is no indication that the search has, essentially, changed from the loaded query because something wasn't available, like a style or font. I.e., if the query was to search for an EN space on the "EXT1" style only and the EXT1 wasn't available ALL EN spaces get found. Obviously, this is NFG.
I know I can read the XML file and check, for instance, to see whether a style is defined in the query, then check the document for that style. But yikes, it would, technically, have to check for swatches, the many other types of styles and what ever else to work 100%.
Short of reading the XML file is there any way to test a query and have the script know something is missing?
Thanks for reading,
loadFindChangeQuery() loads a query, even if the formatting doesn't match, just as you found. Therefore, as you feared, the only way to check if some formatting is available is to look inside the XMLs. And that is feasible only for character-style names -- for local formatting it's pretty much undoable.