Skip to content

Instantly share code, notes, and snippets.

@leonlihkust
Created August 27, 2014 01:17
Show Gist options
  • Save leonlihkust/6ec7b355308e6705cb45 to your computer and use it in GitHub Desktop.
Save leonlihkust/6ec7b355308e6705cb45 to your computer and use it in GitHub Desktop.
Get selected text frame or image id in InDesign document
public function GetSelectedObjectID():String
{
var objectId:String = "";
if(InDesign.app.selection[0] != null)
{
if(InDesign.app.activeDocument.selection[0] is TextFrame)
{
var textObject:TextFrame = InDesign.app.selection[0];
objectId = textObject.id.toString();
}
else
{
if( InDesign.app.activeDocument.selection[0].allGraphics.length != 0 &&
InDesign.app.activeDocument.selection[0].allGraphics[0] is Image)
{
objectId = InDesign.app.activeDocument.selection[0].allGraphics[0].id.toString();
}
}
}
return objectId;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment