[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

(DTPtechNote:1721) Re: [AppleScript][InDesign CS3]ページ番号



on get_section_info(theDocument)
	tell application "Adobe InDesign CS2_J"
		tell theDocument
			set sectionStartNumList to page number start of every section
			set sectionLengthList to length of every section
		end tell
	end tell
	return {pNumStart:sectionStartNumList, sectionLength:sectionLengthList}
end get_section_info

on get_page_num(pageOffset, sectionInfo)
	set {n, i} to {0, 0}
	repeat while n < pageOffset
		set i to i + 1
		set sectionOffset to n
		set n to n + (item i of sectionLength of sectionInfo)
	end repeat
	return pageOffset - sectionOffset + (item i of pNumStart of sectionInfo) - 1
end get_page_num

tell application "Adobe InDesign CS2_J"
	tell document 1
		set sectionInfo to my get_section_info(object reference)
		set docuOffset to document offset of parent of selection
		set pageNum to my get_page_num(docuOffset, sectionInfo)
		set pageName to name of page docuOffset
	end tell
end tell
display dialog "page number: " & pageNum & return & "page name: " & pageName