Home |
Search |
Today's Posts |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have learned something new today Dave.
Thankyou for your kind help. Pat "Dave Peterson" wrote in message ... If the code is executed by clicking on a commandbutton in sheet2, then the code should be in that sheet2 module--even if your _click event calls the routine in the General module. Anyway, I'm guessing that the picture and the commandbutton are both on Sheet1. This is the code that I used for the commandbutton: Option Explicit Private Sub CommandButton1_Click() If TypeName(Selection) = "Picture" Then Selection.ShapeRange.LockAspectRatio = msoFalse Selection.ShapeRange.Height = 70.5 Selection.ShapeRange.Width = 70.5 Selection.ShapeRange.Rotation = 0# Else MsgBox "Please select a picture" End If End Sub But the important thing to change is how that commandbutton is treated. Go into design mode (another icon on the control toolbox toolbar). right click on your commandbutton choose properties change .takefocusonclick to false And close the properties window and get out of design mode. When you clicked on the commandbutton, that became the object selected. And then the code wouldn't work the way you wanted. Pat wrote: Yes only the selected picture. I am getting the message "Please select a picture" even though a picture is selected. I placed the code into module1, then the code is executed from a commandbutton in sheet2. I have become a little bit rusty in using VBA. Pat "Dave Peterson" wrote in message ... Do you want to resize all the pictures on that worksheet? If yes: Option Explicit Sub testme() Dim wks As Worksheet Dim myPict As Picture Set wks = ActiveSheet With wks For Each myPict In .Pictures With myPict.ShapeRange .LockAspectRatio = msoFalse .Height = 70.5 .Width = 70.5 .Rotation = 0 End With Next myPict End With End Sub If only the selected pictu Option Explicit Sub testme() If TypeName(Selection) = "Picture" Then Selection.ShapeRange.LockAspectRatio = msoFalse Selection.ShapeRange.Height = 70.5 Selection.ShapeRange.Width = 70.5 Selection.ShapeRange.Rotation = 0# Else MsgBox "Please select a picture" End If End Sub Pat wrote: ActiveSheet.Shapes("Picture 1").Select Selection.ShapeRange.LockAspectRatio = msoFalse Selection.ShapeRange.Height = 70.5 Selection.ShapeRange.Width = 70.5 Selection.ShapeRange.Rotation = 0# The above will resize Picture 1. I want to resize any selected picture. Much appreciate any help. Pat -- Dave Peterson -- Dave Peterson |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Resize object by HxW using pixels | Excel Discussion (Misc queries) | |||
Resize Picture / object in Excel | Excel Programming | |||
How do I resize a check box form object in Excel? | Excel Discussion (Misc queries) | |||
resize object dosen't take?? | Excel Worksheet Functions | |||
resize object dosen't take??? | Excel Discussion (Misc queries) |