For the above code to work you would need to insure Photoshop units were set to something other than percent. For when Photoshop Units are set to percent the statement "if (myDocument.width < myDocument.height) " would never rotate the canvas it would alway be "if (100% < 100%)" always equal been burned by that...