Many years ago I wrote a program that did some analysis of Adobe InDesign documents that had been generated from a database using templates. I did this for Windows using Object Linking and Embedding (OLE). The code looks something like this:
myInDesign = new OLEObject("InDesign.Application")
myDocument = myInDesign.ActiveDocument
myStory = myDocument.TextFrames.Item(1).ParentStory
iPars = myStory.Paragraphs.Count
For i = 1 to iPars
If myStory.Paragraphs.Item(i).Characters.Count>1 then
firstChar = myStory.Paragraphs.Item(i).Characters.Item(1)
firstCharUnicode = Asc(firstChar.Contents)
...
The client now requires the same thing but on a Mac but I no idea what the OLE equivelent is on Macs. The usual suspects of AppleScript or JavaScript seem only to ‘tell’ the application and not get information from a document.
Can anyone point me in the right direction please?
The ‘Tell’ statements are just a matter of addressing the appropriate objects. Here’s a little snippet which will get the properties of the active document
tell application “Adobe InDesign CS5.5”
set thedoc to active document
set theprops to properties of thedoc
end tell
Fire up ScriptEditor on the Mac. In the app do an “Open function list” (or some such, translated from German). Either select InDesign from the list or click the search button for selecting your app directly.
The window that now opens shows you the objects that can be talked to.
The AppleScript syntax is a horrible mess that looks totally elegant. But it works - mostly. If you want to learn more get Matt Neuburgs book on it. It’s a bit older but nothing much has changed.