PDA

View Full Version : [SOLVED:] Macro to scale shapes



RandomGerman
05-28-2015, 01:31 PM
Hi,

I built a macro to scale shapes the way the user wants it. The funny thing is, it works but goes to error at the same time. I guess it is not a big thing that went wrong with my code (otherwise it wouldn't work), but I'm too blind for it. Can anyone help me to get rid of the error message, which appears anytime I run the macro?

Thanks so much!
RG

Sub ScalingTool()
Dim shp As Shape
Dim Message As String
Dim Title As String
Dim Default As Integer
Dim MyValue As Integer
On Error GoTo err
Message = "Please enter value in % (but without the %-sign)"
Title = "ScalingTool InputBox"
Default = "100"
MyValue = InputBox(Message, Title, Default)

For Each shp In ActiveWindow.Selection.ShapeRange
shp.Width = shp.Width / 100 * MyValue
shp.Height = shp.Height / 100 * MyValue
Next

err:
MsgBox "Select at least one shape"
End Sub

John Wilson
05-29-2015, 12:24 AM
You will always get the error message (even when there's no error with your code because the code will just continue until it reaches the MsgBox

BEFORE err and after NEXT:

Insert

Exit Sub

RandomGerman
05-29-2015, 01:52 AM
I knew it was something like this: One missing command or a spelling mistake or anything else that looks little, but has a great impact ...

Thank you so much, John! It's always helpful to have someone looking on the code with "fresh eyes"!

(Btw: I know, this macro is useless, as it is much easier to drag a cornerpoint of the shape and press SHIFT while pulling ... but I learned a bit about InputBoxes and how to use mathematical formulars within VBA.)