Print All AppleWorks files of specified folder

I’ve been trying different things with the two scripts below. All I want one or both of them to do is print all of the AppleWorks files in a specified folder. I think I’ve got the loop right in either one (as I copied them from other sources) but the print always fails.

I can’t seem to figure out the final step to make AppleWorks actually print the documents. I’ve tried print window 1, print alias, print, etc. I have a bad/good feeling it’s a blatantly obvious mistake. I would appreciate any help.

Thanks,

Tom



set folder_to_print to choose folder with prompt "Choose the folder."

set item_list to list folder folder_to_print without invisibles

repeat with print_item in item_list
	set the_alias to alias ((folder_to_print as string) & (print_item))
	
	tell application "AppleWorks 6"
		open the_alias
		print the_alias
		close window 1
	end tell
end repeat


try
	set the source_folder to "Macintosh HD:Users:teacher:Desktop:trial:" as alias
end try

set the item_list to list folder source_folder without invisibles
set source_folder to sources_folder as string
repeat with I from 1 to number of items in the item_list
	set this_item to item I of the item_list
	set this_item to (source_folder & this_item) as alias
	
	tell application "AppleWorks 6"
		open this_item
		print window 1
		close window 1
	end tell
end repeat

I got it to work in an “ugly” way.

Instead of print * I went with

tell application "System Events"
keystroke "p" using command down
keystroke return
end tell

I’m just wandering around in AppleScript and I’m sure there’s a better/prettier way to do this. So if anyone knows I’d appreciate earasing a small part of my ignorance.

Thanks

Thank you, Jaques.

I knew it was something distressingly simple. I read about the window needing to be in the front in the dictionary but I figured if everything else was closed then it would have to recognize the AW document as being in front. I guess not.

I appreciate it and thanks again,

Tom