Created
August 27, 2014 01:17
-
-
Save leonlihkust/6ec7b355308e6705cb45 to your computer and use it in GitHub Desktop.
Get selected text frame or image id in InDesign document
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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