If you don't mind using undocumented procedures, you can simplify it slightly by replacing all the loop stuff with:
exec sp_msforeachtable @command1='insert #TempTable exec sp_spaceused ''?'''
I also convert the "KB" values from sp_spaceused into numbers to allow for easier manipulation.