Consulting

Results 1 to 3 of 3

Thread: Macro to scale shapes

  1. #1
    VBAX Contributor
    Joined
    Apr 2015
    Location
    Germany
    Posts
    167
    Location

    Macro to scale shapes

    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

  2. #2
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    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
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  3. #3
    VBAX Contributor
    Joined
    Apr 2015
    Location
    Germany
    Posts
    167
    Location
    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.)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •