Article View: adobe.scripting.indesign
Article #18979Re: "row" on page 1 or on page 2? Is there a way?
From: Armin.Egginger
Date: Tue, 11 Feb 2003 13:31
Date: Tue, 11 Feb 2003 13:31
58 lines
2959 bytes
2959 bytes
Hi Scripter,
I need this for my project and needs your help. Is it possible, that anybody can translate the VB script from Olav to AppleScript?
The script:
Private Sub Command1_Click()
Dim myInDesign As InDesign.Application
Set myInDesign = CreateObject("InDesign.Application.2.0")
Rem Clear the find/change attributes.
myInDesign.FindPreferences = idNothing
myInDesign.ChangePreferences = idNothing
Set myDocument = myInDesign.ActiveDocument
Rem Get a reference to an example cell.
Set myCell = myDocument.Stories.Item(1).Tables.Item(1).Rows.Item(15).Cells.Item(1)
Rem Enter some unique string to search for (keep it relatively short, so that the cell won't be pushed to another page).
myFindString = "!!"
Rem Enter the string in the cell.
myCell.InsertionPoints.Item(1).TextContents = myFindString
Rem Find the page number.
myPageNumber = myFindCellParentPage(myDocument, myFindString)
If myPageNumber <> "Not found" Then
MsgBox "Cell appears on page " & CStr(myPageNumber)
Else
MsgBox "Cell was not found."
End If
Rem Now clean up the text we entered in the cell.
For myCounter = 1 To Len(myFindString)
myCell.Characters.Item(1).Delete
Next
Rem And do whatever it is you want to do with the page number.
End Sub
Private Function myFindCellParentPage(myDocument, myFindString)
For myPageCounter = 1 To myDocument.Pages.Count
Set myPage = myDocument.Pages.Item(myPageCounter)
For myTextFrameCounter = 1 To myPage.TextFrames.Count
Set myTextFrame = myPage.TextFrames.Item(myTextFrameCounter)
Set myNewTextFrame = myTextFrame.Duplicate
Set myFoundItems = myNewTextFrame.Search(myFindString, False, False)
If myFoundItems.Count <> 0 Then
Rem Found the text, so the page containing the cell is the parent of myNewTextFrame
myPageNumber = myNewTextFrame.Parent.Name
myNewTextFrame.Delete
myFindCellParentPage = myPageNumber
Exit Function
Else
myNewTextFrame.Delete
End If
Next
Next
myFindCellParentPage = "Not found"
End Function
I never scripted in VB and I'm a beginner in AS. Pls help.
Many thanks
Armin
Technical Details
Message-ID:
<1de78f51.6@WebX.la2eafNXanI>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!ngpeer.news.aol.com!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebXReferences:
<1de78f51.-1@WebX.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f939a,7203538a108a08cc X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2003-02-11 05:37:56 PST From: Armin.Egginger <armin.egginger@gmx.de> Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!ngpeer.news.aol.com!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebX Newsgroups: adobe.scripting.indesign Subject: Re: "row" on page 1 or on page 2? Is there a way? Message-ID: <1de78f51.6@WebX.la2eafNXanI> Date: Tue, 11 Feb 2003 05:31:48 -0800 References: <1de78f51.-1@WebX.la2eafNXanI> Lines: 63 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit