Need help setting .Min and .Max for Active X spinner

OaklandJim

Well-known Member
Joined
Nov 29, 2018
Messages
833
Office Version
  1. 365
Platform
  1. Windows
I am attempting to implement dynamic .Min and .Max properties of an ActiveX spinner. I've tried to research this but I've gotten nowhere. I tried supposed solutions that I could find on-line but nothing I tried works. What simple thing am I missing?

Bonus question: does resizing shown address key ActiveX controls' sporadic resizing issue?

Here is hacked up code

VBA Code:
Private Sub SpinButton1_Change()

    'Dim oSpinner As OLEObject
   
    Dim oSpinner As Shape
   
    Dim iMinValue As Long
   
    Dim iMaxVal As Long
   
    Dim iSpinner1Height As Long
   
    Dim iSpinner1Width As Long
   
    'Set oSpinner = Me.OLEObjects("SpinButton1")
    'Set oSpinner = Me.Shapes("SpinButton1")
   
'   Get height and width from defined names' RefersTo field.
    iSpinner1Height = [Spinner1Height]
    iSpinner1Width = [Spinner1Width]
   
'   Determine .Min and .Max values for the spinner.
    iMinValue = 5
    iMaxVal = 100 - Me.Range("C2").Value
   
    With Me.OLEObjects("SpinButton1")
       
'       Set spinner height and width.
        .Height = iSpinner1Height
       
        .Width = iSpinner1Width
       
'       Object does not support this property or method
        .Min = iMinValue
       
'       Object does not support this property or method
'        .ControlFormat.Min = iMinValue
   
    End With
   
'   Type Mismatch error if oSpinner is defined as an OLEObject
'   And Object does not support this property or method if oSpinner
'   is defined as Object or shape
    oSpinner.ControlFormat.Min = iMinValue

End Sub
 
Your second post was the solution. It gave me what was needed when I was fiddling with the ActiveX Control. I also tried form spinner before ActiveX but it did not work for me.

You'll get a laugh from this, I suspect, but because ActiveX controls are so notorious for bad behavior, for the need of the person that I was helping I built my own spinner from grouped shapes. It works well. I was surprised that I could use grouped shapes but it works.

I really do appreciate all of your input. Thank you!
 
Upvote 0

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

Forum statistics

Threads
1,215,148
Messages
6,123,301
Members
449,095
Latest member
Chestertim

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top