Looking at your script, it does work - at least, it does exactly what you ask it to.
It might not do what you want, but that's a different issue :)
Specifically, there's nothing in your script that iterates through the files in the folder, so that's the first change you need.
In addition, you need to extract metadata related to the image files, and that's actually easier via shell commands, so I'd incorporate that into the script.
Finally (for now), it's actually easier to write to a tab-delimtied text file and then open that in Excel. Much easier than trying to manipulate Excel directly.
Here's a script that will do that. It first asks for a folder, then grabs a list of JPEG images in that folder.
Then it iterates through that list, extracting the file name, image height and image width data, writing it out to a text file.
At the end of the script it instructs Excel to open that text file, which Excel does, automatically translating tab-delimited text into columns.
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
-- prompt the user for the folder to process
-- this could be fixed if you prefer
set theFolder to choose folder
-- define the name of the output file to create
set outputFilename to "images.txt"
-- and make a new file
set theOutputFile to makeNewFile(outputFilename)
-- write a header column to the file
my writeToFile(theOutputFile, "Name" & tab & "Height" & tab & "Width")
-- ask the Finder...
tell application "Finder"
-- to get a list of all the JPEG images in the folder
set theFiles to (every file of folder theFolder whose kind is "JPEG image") as alias list
-- for each file...
repeat with eachFile in theFiles
-- get its POSIX path (needed for the shell script)
set qp to quoted form of POSIX path of eachFile
-- extract the file name
set fn to name of eachFile
-- use a shell script to get the image height
set imageHeight to last word of (do shell script "mdls -name kMDItemPixelHeight " & qp)
-- use another shell script to get the image width
set imageWIdth to last word of (do shell script "mdls -name kMDItemPixelWidth " & qp)
-- and write that data to the file
my writeToFile(theOutputFile, fn & tab & imageHeight & tab & imageWIdth)
end repeat
end tell
-- once we're done, close the file
close access theOutputFile
-- and tell Excel to open it
tell application "Microsoft Excel" to open ((get path to desktop) & outputFilename as text)
on makeNewFile(theFileName)
-- this defines a new file
set theFile to open for access (file ((get path to desktop) & theFileName as text)) with write permission
-- clears out any existing data
set eof theFile to 0
-- and passes it back
return theFile
end makeNewFile
on writeToFile(theFile, theText)
-- simple append-write to the file
write theText & return to theFile
end writeToFile