script OK in iPhoto v9 but KO in iPhoto v8

Hello

Hello

I am learning Applescript because I need it for iPhoto script.
I have a problem in a script to assign a keyword to all photos of an album.

First I tried that (the keyword I want to assign already exists) :

tell application "iPhoto"
	activate
	set theEvents to get every album
	repeat with aEvent in theEvents
	set typalb to (get type of aEvent)
	if typalb = regular album then
		if  name of aEvent = "my Birthday" then
			set myAlbum to (get name of aEvent)
			set newkw to "xy_" & myAlbum
			
			tell album myAlbum
				select photos
				assign keyword string newkw
			end tell
			
		end if
	end if
end tell

It works well with iPhoto’11 (v9.5) but does not work with iPhoto’09 (v8.0).

I got the AppleScript error :

I see in iPhoto window that all pictures of my album are selected

I tried also this code to loop on photos :

...
			tell album myAlbum
				set allPix to photos
				repeat with onePix in allPix
					select onePix
					assign keyword string newkw
				end repeat
...

but I got the same Applescript error although the first picture of the album is selected in iPhoto window.

What’s wrong ?
Thanks a lot.

Sergio

I made many trials and finally my script is OK when I just remove “tell album myAlbum” !!
Sergio