PDA

View Full Version : Solved: Forms - creating a wizard with moving parts



philfer
12-03-2009, 07:40 AM
Hello,

Is it possible using a Userform to create a wizard that has moving parts like Excel 2003's Pivottable wizard (i.e. labels with field names can be moved and dropped into the pivottable zones). I have tried it with labels but they are fixed when the Form is displayed

Any help would, as always, be appreciated

All the best
Phil

mikerickson
12-03-2009, 07:59 AM
If you put this in a userform's code module, you can drag Label1 around the userform with the mouse.
Dim xNull As Long, yNull As Long
Dim Work As Boolean

Private Sub Label1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Single, ByVal y As Single)
xNull = x
yNull = y
Work = True
End Sub

Private Sub Label1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Single, ByVal y As Single)
If Work Then
With Label1
.Left = .Left + (x - xNull)
.Top = .Top + (y - yNull)
End With
End If
End Sub

Private Sub Label1_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Single, ByVal y As Single)
Work = False
End Sub