LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
Pat Pat is offline
external usenet poster
 
Posts: 122
Default Resize any selected object

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Resize object by HxW using pixels WA Excel Discussion (Misc queries) 1 May 6th 10 01:23 AM
Resize Picture / object in Excel frenchky_007 Excel Programming 0 May 31st 07 10:37 PM
How do I resize a check box form object in Excel? bpoole Excel Discussion (Misc queries) 1 May 11th 06 06:38 PM
resize object dosen't take?? Gary Excel Worksheet Functions 1 March 21st 05 06:39 PM
resize object dosen't take??? gary Excel Discussion (Misc queries) 0 March 20th 05 10:39 PM


All times are GMT +1. The time now is 06:57 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"