![]() |
Resizing a Picture
Hello,
Could some one please help me with the following? I need a macro that when a user selects a picture on my spreadsheet (named "items") then the macro will automatically format the selected picture with the following format picture criteria: Height = 10.11cm Width = 14.92cm Height = 253% Width = 249% lock aspect ratio = true relative to original picture size = true Original size = 4cm Height x 6cm Width Any help would be greatly appreciated. Thanks, Chris. Live Long and Prosper :-) *** Sent via Developersdex http://www.developersdex.com *** |
Resizing a Picture
start the macro recorder
select a picture & resize it the way you want it. end the macro recorder see what you've got! (hint - remove the "selection" part, so it will work with whatever picture is selected). :) susan On Mar 28, 7:24 am, Longbow wrote: Hello, Could some one please help me with the following? I need a macro that when a user selects a picture on my spreadsheet (named "items") then the macro will automatically format the selected picture with the following format picture criteria: Height = 10.11cm Width = 14.92cm Height = 253% Width = 249% lock aspect ratio = true relative to original picture size = true Original size = 4cm Height x 6cm Width Any help would be greatly appreciated. Thanks, Chris. Live Long and Prosper :-) *** Sent via Developersdexhttp://www.developersdex.com*** |
Resizing a Picture
Hi Susan,
Thanks for your reply. I ran the following macro and received a run-time error stating that the item with the specified name could not be found. Sub Macro3() ' ' Macro3 Macro ' Macro recorded 28/03/2007 by User ' ' ActiveSheet.Shapes("Picture 21").Select Selection.ShapeRange.ScaleWidth 2.48, msoFalse, msoScaleFromTopLeft Selection.ShapeRange.ScaleHeight 2.48, msoFalse, msoScaleFromTopLeft Selection.ShapeRange.ScaleHeight 1.02, msoFalse, msoScaleFromTopLeft End Sub The first line of my macro code will not run according to the VBE that highlights it in yellow after I debug the run-time error. Could you please advise on how I can get around this problem. Many thanks, Chris. Live Long and Prosper :-) *** Sent via Developersdex http://www.developersdex.com *** |
Resizing a Picture
good! yes, as to the problem you're having, remove this statement:
ActiveSheet.Shapes("Picture 21").Select every time you add a shape or a picture, excel gives it a different #. it's hard to keep track of them, because if you delete, say, picture15, the next one inserted will not be another picture15, but will be picture22 (or whatever # comes after the last one you inserted). if you take that line out, you can select a picture, any picture, and run the macro, & it will reshape that one picture. so if you add this macro to a toolbar button, you can select the picture, and push the button, & it will reshape it. hope this helps! susan On Mar 28, 8:34 am, Longbow wrote: Hi Susan, Thanks for your reply. I ran the following macro and received a run-time error stating that the item with the specified name could not be found. Sub Macro3() ' ' Macro3 Macro ' Macro recorded 28/03/2007 by User ' ' ActiveSheet.Shapes("Picture 21").Select Selection.ShapeRange.ScaleWidth 2.48, msoFalse, msoScaleFromTopLeft Selection.ShapeRange.ScaleHeight 2.48, msoFalse, msoScaleFromTopLeft Selection.ShapeRange.ScaleHeight 1.02, msoFalse, msoScaleFromTopLeft End Sub The first line of my macro code will not run according to the VBE that highlights it in yellow after I debug the run-time error. Could you please advise on how I can get around this problem. Many thanks, Chris. Live Long and Prosper :-) *** Sent via Developersdexhttp://www.developersdex.com*** |
Resizing a Picture
Thanks again Susan - your help was terrific and much appreciated.
Cheers, Chris. Live Long and Prosper :-) *** Sent via Developersdex http://www.developersdex.com *** |
All times are GMT +1. The time now is 01:05 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com