Filling Word Table from FMP

I’ve tried to script this process, but I believe I’m running into a dead end. The process is a calculated applescript from within FileMaker that would export multiple records to an applescript created table in Word. I’m having trouble processing fields into cells.

More or less here is the code (this is a calculated AS in FMP)

"tell application \"Microsoft Word\"¶
	set row1 to \"2\"¶
	make new table at active document with properties {number of columns:2, number of rows:row1}¶
	tell font object of selection¶
		set name to \"Times New Roman\"¶
		set bold to true¶
		set font size to 10¶
	end tell¶
	set enable borders of border options of table 1 of active document to false¶
	tell paragraph format of selection to set alignment to align paragraph left¶
	type text selection text \""  & PieceSelect::Title & "\"¶

	tell font object of selection¶
		set name to \"Times New Roman\"¶
		set bold to false¶
		set font size to 10¶
	end tell¶
	tell paragraph format of selection to set alignment to align paragraph right¶
	type text selection text \""  & PieceSelect::Composer & "\"¶

Or straight from AS editor…(without the FMP stuff)

tell application "Microsoft Word"
	set row1 to "2"
	make new table at active document with properties {number of columns:2, number of rows:row1}
	tell font object of selection
		set name to "Times New Roman"
		set bold to true
		set font size to 10
	end tell
	set enable borders of border options of table 1 of active document to false
	tell paragraph format of selection to set alignment to align paragraph left
	type text selection text "PieceSelect::Title "
	
	
	tell font object of selection
		set name to "Times New Roman"
		set bold to false
		set font size to 10
	end tell
	tell paragraph format of selection to set alignment to align paragraph right
	type text selection text "  & PieceSelect::Composer "

I was planning to do the repeating using the Loop function in FMP, but would it be better to use a AS function calling portal records? Any help or direction or saying “you’re way off try this way” would be appreciated.

jon

If you are using all the records in the database then you can use something like this.


tell application "FileMaker Pro Advanced"
	tell database "YourDatabase"
		tell table "PieceSelect"
			set titles to field "Title"
			set composers to field "Composer"
		end tell
	end tell
end tell

(*
	This will give you a list for both title and composer
	then loop through the list. 
*)

repeat with i from 1 to count of titles
	set thisTitle to item i of titles
	set thisComposer to item i of composers
	
	--do your stuff here
end repeat

To get the current record in FM database you talk to
the database and the current record and you set your variable
to a cell instead of a field. A field returns a list but only if
you talk to the Window, Table or Layout.


tell application "FileMaker Pro Advanced"
	tell database "YourDatabase"
		tell current record
			set title to cell "Title"
			set composer to cell "Composer"
		end tell
	end tell
end tell

Cheers!

Craig