2 Replies Latest reply on Mar 6, 2013 11:48 AM by mmargeta

    How to find out selected AssignedStory or Link?

    mmargeta Level 1

      Hello to all,


      can anyone pls. explain how to find out which assigned story or link is selected at the time the script is fired.


      My problem is this: I would like to place an image into selected rectangle which is exported into .icml. So, for example, you have few exported rectangles and you would like to place an image into the one which is selected (through link or assignment panel). Because you can not select a rectangle in InCopy like you can in InDesign I tried to take a look through assigned stories...


                         For aCounter As Integer = 1 To myDocument.Assignments.Count
                              Dim myAssignment As InCopy.Assignment = myDocument.Assignments.Item(aCounter)
                              For sCounter As Integer = 1 To myAssignment.AssignedStories.Count
                                  Dim myAssignedStory As InCopy.AssignedStory = myAssignment.AssignedStories.Item(sCounter)
                                  Dim myStoryRef As Object = myAssignedStory.StoryReference
                                  find out if assigned story or story reference is selected

                                  'Rectangle                             If TypeName(myStoryRef) = "Rectangle" Then                                 Dim myObjectRectangle As InCopy.Rectangle = myStoryRef                                 If myObjectRectangle.Graphics.Count = 0 And myObjectRectangle.Images.Count = 0 Then                                     'CheckOut if needed                                     'Place Media                                 End If                             End If                         Next                     Next


      Kind regards,


        • 2. Re: How to find out selected AssignedStory or Link?
          mmargeta Level 1



          I couldn't solve this without using a placeholder image. I found that you need to check if the selection is an image and than replace that image... So something like this below:


                          'Check if there is a selected image for relink
                          If myDocument.Selection.Count = 1 Then
                              If TypeName(myDocument.Selection.Item(1)) = "Image" Then
                                  myImage = myDocument.Selection.Item(1)
                                  myImageLink = myImage.ItemLink
                                  Dim msgRet As MsgBoxResult = MsgBox("Would you like to relink selected image?", MsgBoxStyle.YesNoCancel, "Relink seleceted image?")
                                  If msgRet = MsgBoxResult.Yes Then
                                              ' DO some action                                     Dim MediaLink As String = something...                                             ' ------------------------------------------                                             'CheckOut action                                             If myCheckOutMenu.AssociatedMenuAction.Enabled() Then                                                 myCheckOutMenu.AssociatedMenuAction.Invoke()                                             End If                                             myImageLink.Relink(fileLink)                                             Try                                                 myImageLink.Update()                                             Catch                                             End Try


          Hope this helps.