In X5 - size transform incremental - spinner

Is it possible to add up/down arrow beside the text boxes (spinner) to adjust the height and width of an object by clicking with a mouse?

Parents
No Data
Reply
  • Hello, everybody,

    I will suggest a macro code

    You must have:
    - a not modale userform
    - controls on userform:
          - tbWidth - text box
          - tbHeight - text box
          - tbStep - text box
          - SpinButton1

    Code UserForm_Activate:
    SpinButton1.Enabled = False
    On Error Resume Next
    tbHeight.Value = Val(ActiveShape.SizeHeight * 25.4)
    On Error Resume Next
    tbWidth.Value = Val(ActiveShape.SizeWidth * 25.4)
    tbStep.Value = 1
    ---------------------------------------------------------------------------------

    Private Sub GlobalMacroStorage_SelectionChange()
    On Error Resume Next
    ufCommands.tbWidth.Value = ActiveShape.SizeWidth * 25.4 'my units are millimeters
    On Error Resume Next
    ufCommands.tbHeight.Value = ActiveShape.SizeHeight * 25.4
    End Sub
    ---------------------------------------------------------------------------------
    Private Sub tbWidth_Enter()
    SpinButton1.Enabled = True
    acName = ActiveControl.Name
    End Sub
    ---------------------------------------------------------------------------------
    Private Sub tbHeight_Enter()
    SpinButton1.Enabled = True
    acName = ActiveControl.Name
    End Sub
    ---------------------------------------------------------------------------------
    Private Sub SpinButton1_SpinDown()
    'MsgBox acName
    Me.Controls(acName).Value = Val(Me.Controls(acName).Value) - Val(tbStep.Value)
    If acName = "tbWidth" Then
    ActiveShape.SizeWidth = Val(Me.Controls(acName).Value) / 25.4
    End If
    If acName = "tbHeight" Then
    ActiveShape.SizeHeight = Val(Me.Controls(acName).Value) / 25.4
    End If
    'tbHeight.Value = tbHeight.Value - 1
    'MsgBox acName
    End Sub
    Private Sub SpinButton1_SpinUp()
    'MsgBox acName
    'tbHeight.Value = tbHeight.Value + 1
    Me.Controls(acName).Value = Val(Me.Controls(acName).Value) + Val(tbStep.Value)
    If acName = "tbWidth" Then
    ActiveShape.SizeWidth = Val(Me.Controls(acName).Value) / 25.4
    End If
    If acName = "tbHeight" Then
    ActiveShape.SizeHeight = Val(Me.Controls(acName).Value) / 25.4
    End If
    End Sub
    At declaration level of UserForm:
    Public acName As String

    A little code explanation:
    When UserForm is activated SpinButton1 is disabled
    A click with mouse in tbWidth or tbHeight will enable SpiButton1 and acName=ActiveControl.name    'tbWidth or tbHeight
    SpinUp/SpinDown will change values in acName control 'tbWidth or tbHeight with value of tbStep.value 'default is 1, see UserForm_Activate above

    The code below make it possible to select difrent shapes when modeless UserForm is open. Put actual size values of selected/active shape in tbWidth and tbHeight. Changing of size with tbStep.value Up/Down is possible for each active shape.
    Private Sub GlobalMacroStorage_SelectionChange()
    On Error Resume Next
    ufCommands.tbWidth.Value = ActiveShape.SizeWidth * 25.4
    On Error Resume Next
    ufCommands.tbHeight.Value = ActiveShape.SizeHeight * 25.4
    End Sub

    Better code can certainly be written.
    Greetings!

Children
No Data