Macro question

Would it be possible to create a macro that looks at visible objects (and/or groups of objects) and resizes them automatically?  They would need to be either a specific height or width and never larger than either dimension.  For example - if the max height was .5" and the max width was 1" and if the partiicular object is enlarged to .5" tall and that makes it more than 1" wide then it would resize to the 1" width instead, and vice versa.  Hopefully this makes sense.