|
訂正です。
>作成したUserform1のモジュールには
>
> '===============================================================
>Option Explicit
>Private s_w As Double
>Private s_h As Double
>Private WithEvents sp_h As MSForms.SpinButton
>Private WithEvents sp_v As MSForms.SpinButton
Private spd As object ' ←ここのデータの型を変更してください
> '=============================================================
>Private Sub sp_h_SpinDown()
> Me.Width = Me.Width - 6
> spd.Width = spd.Width * Me.Width / s_w
> reset_spin
>End Sub
> '=============================================================
>Private Sub sp_h_SpinUp()
> Me.Width = Me.Width + 6
> spd.Width = spd.Width * Me.Width / s_w
> reset_spin
>End Sub
> '=============================================================
>Private Sub sp_v_SpinDown()
> Me.Height = Me.Height + 6
> spd.Height = spd.Height * Me.Height / s_h
> reset_spin
>End Sub
> '=============================================================
>Private Sub sp_v_SpinUp()
> Me.Height = Me.Height - 6
> spd.Height = spd.Height * Me.Height / s_h
> reset_spin
>End Sub
> '=============================================================
>Private Sub reset_spin()
> With sp_h
> .Width = 54
> .Height = 24
> .Left = Me.Width - .Width - 50
> .Top = Me.Height - .Height - 25
> End With
> With sp_v
> .Width = 24
> .Height = 54
> .Left = Me.Width - .Width - 12
> .Top = Me.Height - .Height - 50
> End With
>End Sub
> '=============================================================
>Private Sub UserForm_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
> If sp_h Is Nothing Then
> With Me
> Set sp_h = .Controls.Add("Forms.SpinButton.1", , True)
> Set sp_v = .Controls.Add("Forms.SpinButton.1", , True)
> End With
> reset_spin
> Else
> Controls.Remove sp_h.Name
> Controls.Remove sp_v.Name
> Set sp_h = Nothing
> Set sp_v = Nothing
> End If
>End Sub
> '=============================================================
>Private Sub UserForm_Initialize()
> With Me
> .Width = 425
> .Height = 350
> s_w = .Width
> s_h = .Height
> End With
> Set spd = Controls.Add("OWC.Spreadsheet.9", , True)
> With spd
> .Left = 0
> .Top = 0
> .Width = 200
> .Height = 150
> .AutoFit = True
> End With
> Set sp_h = Nothing
> Set sp_v = Nothing
>End Sub
>
>
>以上です。sampを実行してみてください。
>
>Userform1には、スプレッドシートが表示されていますよね?
>
>ユーザーフォームのスプレッドシート以外の箇所をダブルクリックしてください。
>隅にスピンボタンが表示されます。
>
>クリックして下さい。ユーザーフォームのサイズが変更されます。
>(再度、ダブルクリックすると、スピンボタンが消えます)
>
>今回は、スプレッドシートだけですが、他にコントロールがあれば、
>その制御もしなければなりません。
>
>試してみてください。
|
|