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

(DTPtechNote:1253) [AS Indesign CS] print-current-page.as

なんかものすごーく遠回りしてますが、current pageがすぐにgetできないので。

(c)2005 www.seuzo.jp

ver0.1	とりあえず

set my_preset to ("A4_ぺら+トンボ" as Unicode text)

tell application "InDesign CS_J"
	tell document 1
		set my_selection to object reference of selection
		if my_selection is {} then my my_error("印刷するページにある、なにかひとつを選択してください", true)
		set my_page to my getpage(my_selection)
		tell print preferences
			set page range to my_page
		end tell
		print using my_preset without print dialog
	end tell
end tell

to getpage(my_selection)
	tell application "InDesign CS_J"
		tell document 1
			if (class of my_selection) = page then
				return name of my_selection
				set my_tmp to parent of my_selection
				if class of my_tmp = story then set my_tmp to parent of parent text frame of my_selection
				my getpage(my_tmp)
			end if
		end tell
	end tell
end getpage

on my_error(err_str, my_stop)
	set err_str to err_str as Unicode text
	if my_stop then
		set my_stop to {"中止"}
		set my_stop to {"中止", "続行"}
	end if
	tell application "InDesign CS_J"
		set ANS to button returned of (display dialog err_str buttons my_stop with icon 2) --警告ダイアログ出してストップ
		if ANS is "中止" then error number -128
	end tell
end my_error