export as rtfd with Pages

Hello

I wrote a small script to export some datas grabbed from Numbers as .rtfd.

I copy a chart and its legend in the clipboard then run the script.

tell application "Pages"
	make new document
	my pasteIt()
	save front document
	set p_natif to get path of front document
end tell

tell application "System Events" to tell disk item (p_natif as text)
	set n to name
	set d to path of container
end tell

if n ends with ".pages" then set n to text 1 thru -7 of n
set p_xport to (d as text) & n & ".doc"
tell application "Pages" to save front document as "SLDocumentTypeMSWord" in p_xport
set p_xport to (d as text) & n & ".pdf"
tell application "Pages" to save front document as "SLDocumentTypePDF" in p_xport
set p_xport to (d as text) & n & ".txt"
tell application "Pages" to save front document as "SLDocumentTypePlainText" in p_xport
set p_xport to (d as text) & n & ".rtf"
tell application "Pages" to save front document as "SLDocumentTypeRichText" in p_xport
set p_xport to (d as text) & n & ".rtfd"
tell application "Pages" to save front document as "SLDocumentTypeRichTextBundle" in p_xport

on pasteIt()
	tell application "Pages" to activate
	tell application "System Events" to tell (first process whose title is "Pages") to tell document 1 to keystroke "v" using {command down}
end pasteIt

All works well except the attempt to export as .rtfd.
The result is not a .rtfd file but a .rtfd.pages document.

Is one of you knowing a working syntax or am I facing a bug ?

Yvan KOENIG (from FRANCE mardi 21 octobre 2008 12:18:57)