Copy link to clipboard
Copied
How do I execute "Go To Selected Marker" on the Index panel using a script?
I want to write a script that generates a small text frame next to each index marker with the index entry written in the text frame.
==
Dim myDocument As InDesign.Document
Dim myIndex As InDesign.Index
Dim myPageReference As InDesign.PageReference
For i = 1 To myInDesign.Documents.Count Step 1
myDocument = myInDesign.Documents.Item(i)
Dim pageRefCount As Integer = 0
For j = 1 To myDocument.Indexes.Count
myIndex = myDocument.Indexes.Item(j)
For k = myIndex.AllTopics.Count To 1 Step -1
myPageReference = myIndex.AllTopics.Item(k).PageReferences.Item(1)
' Go To myPageReferennce Marker
' Get the marker coordinates
' Create a text frame
' Enter the index entry in the text frame
Next
Next
Next
==
Thank you in advance.
Tak
Copy link to clipboard
Copied
I was able to figure this out. Not well documented, but below is the code if anyone is interested.
==============================
Dim myDocument As InDesign.Document
Dim myIndex As InDesign.Index
' Dim myPage As InDesign.Page
' Dim myPageReference As InDesign.PageReference
Dim myTextFrame As InDesign.TextFrame
Dim myGeometricBounds(3) As Double
Dim myInDexColor() As Integer = {0, 0, 90, 0}
Dim myIndexTextColor() As Integer = {98, 66, 0, 0}
For i = 1 To myInDesign.Documents.Count Step 1
myDocument = myInDesign.Documents.Item(i)
myAddColor(myDocument, "IndexingColor", InDesign.idColorModel.idProcess, myInDexColor)
myAddColor(myDocument, "IndexingTextColor", InDesign.idColorModel.idProcess, myIndexTextColor)
Dim pageRefCount As Integer = 0
For j = 1 To myDocument.Indexes.Count
myIndex = myDocument.Indexes.Item(j)
For k = myIndex.AllTopics.Count To 1 Step -1
If myIndex.AllTopics.Item(k).PageReferences.Count > 0 Then
For iPageReference = 1 To myIndex.AllTopics.Item(k).PageReferences.Count
myPageReference = myIndex.AllTopics.Item(k).PageReferences.Item(iPageReference)
' Set the geometric bounds based on the insertion point of the source text
myGeometricBounds(0) = myPageReference.SourceText.InsertionPoints.Item(1).baseline
myGeometricBounds(1) = myPageReference.SourceText.InsertionPoints.Item(1).horizontaloffset
myGeometricBounds(2) = myPageReference.SourceText.InsertionPoints.Item(1).baseline + 4
myGeometricBounds(3) = myPageReference.SourceText.InsertionPoints.Item(1).horizontaloffset + 150
' Create the text frame
myPage = myPageReference.SourceText.ParentTextFrames.Item(1).ParentPage
myTextFrame = myPage.TextFrames.Add()
myTextFrame.GeometricBounds = myGeometricBounds
myTextFrame.FillColor = myDocument.Colors.Item("IndexingColor")
myTextFrame.FillTransparencySettings.BlendingSettings.Opacity = 70
myTextFrame.StrokeColor = myDocument.Colors.Item("Black")
myTextFrame.Contents = myPageReference.Parent.Name
' If the topic is a subtopic, make the textframe contents "topic : subtopic"
' Currently only supports two topic levels.
If myPageReference.Parent.Parent.Name <> "" Then
myTextFrame.Contents = myPageReference.Parent.Parent.Name & " : " & myTextFrame.Contents
End If
' Set the text frame's font size and color
myTextFrame.ParentStory.PointSize = 10
myTextFrame.ParentStory.FillColor = myDocument.Colors.Item("IndexingTextColor")
myTextFrame.Fit(InDesign.idFitOptions.idFrameToContent)
' Make the text frame a little bigger to give a margin on the right
myGeometricBounds(3) = myTextFrame.GeometricBounds(3) + 2
myTextFrame.GeometricBounds = myGeometricBounds
Next
End If
Next
Next
Next
==================