applescript not counting images in a Pages document
I'm trying to delete all the images in a Pages document using Applescript. The document was created by pasting an online chat transcript into a blank Pages document. I now want to strip out the avatars. I'm new to applescripting in Pages and have a simple script:
tell application "Pages"
activate
tell front document
get the count of images
end tell
end tell
which i thought should tell me how many images were in the document. It works with some other Pages documents, but not this one:
(I've abbreviated the actual transcript!). Please can anyone tell me why the count is zero?
Apologies if this is the wrong Community.
MacBook Pro with Retina display, OS X El Capitan (10.11.6)