(VBS CS2) Need indexing help: Creating a page reference
This is my first post on this forum. While I have years of experience in PageMaker scripting, I am new to InDesign scripting. I need to create a current page reference and index the word, "Widgets." I've read PDF's until my brain has turned to mush. I can't seem to connect the dots (literally) when it comes to this task.
This is my test script. The last line is where I am stuck:
Const idCurrentPage = 1668444263
Rem Hello World
Set myInDesign = CreateObject("InDesign.Application.CS2")
Rem Create a new document.
Set myDocument = myInDesign.Documents.Add
Rem Get a reference to the first page.
Set myPage = myDocument.Pages.Item(1)
Rem Create a text frame.
Set myTextFrame = myDocument.TextFrames.Add
Rem Specify the size and shape of the text frame.
myTextFrame.GeometricBounds = Array("0p0", "0p0", "18p0", "18p0")
Rem Enter text in the text frame.
myTextFrame.Contents = "This is the new WidgetPro."
Rem Create a new story.
Set myStory = myInDesign.ActiveDocument.Stories(1)
Rem Open the story editor.
Set myStoryEditor = myInDesign.ActiveDocument.Stories(1).StoryEdit
Rem Enter some text.
myStory.insertionPoints.item(-1).contents = vbCr
myStory.insertionPoints.item(-1).contents = "Widgets"
Rem Create an index (not sure if this is needed).
Set myIndex = myDocument.indexes.add()
Rem Add a topic (not sure if this is needed).
Set myTopic = myIndex.Topics.add("Widgets")
Rem Set a reference to the current page DOES NOT WORK
myTopic.pageReferences.add(myStory.insertionPoints[myIndex], PageReferenceType.CurrentPage)
A bit more info if it helps: This process of building the story with corresponding indexed words/phrases continues on through 30+ chapters totalling 500+ pages in the final book. The actual index is at the end of the book will be created through the normal InDesign menu commands.
-Ike