Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Moving a label on a form at run time.

Is there a way to allow a user to move (drag and drop) a text box or a label
on an open form? I want the user to be able to place a "note" on the form,
but once the box opens, I need them to be able to move it around on the page
similar to the way one can move a Post It note. I am running Excel 2003.

Tony

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Moving a label on a form at run time.


Hello Tony,

Where are these objects? On a worksheet or a VBA UserForm?

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.thecodecage.com/forumz/member.php?userid=75
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=50104

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 449
Default Moving a label on a form at run time.

Hi Tony

Here on a Userform, dragging Label1 around:

Option Explicit ' *********** top pof module ************

Dim x0 As Long, y0 As Long

Private Sub Label1_MouseDown(ByVal Button As Integer, _
ByVal Shift As Integer, _
ByVal X As Single, ByVal Y As Single)
x0 = X
y0 = Y
End Sub

Private Sub Label1_MouseMove(ByVal Button As Integer, _
ByVal Shift As Integer, _
ByVal X As Single, ByVal Y As Single)
If Button = 1 Then
Label1.Top = Label1.Top + Y - y0
Label1.Left = Label1.Left + X - x0
End If
End Sub

HTH. Best wishes Harald

"Tony" wrote in message
...
Is there a way to allow a user to move (drag and drop) a text box or a
label on an open form? I want the user to be able to place a "note" on the
form, but once the box opens, I need them to be able to move it around on
the page similar to the way one can move a Post It note. I am running
Excel 2003.

Tony


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default Moving a label on a form at run time.

Harald -

Pretty cool, as always. I made some refinements to keep the label within the
confines of the userform:

'''''''''''''''''''''''''''
Option Explicit

Dim x0 As Long, y0 As Long

Private Sub Label1_MouseDown(ByVal Button As Integer, _

ByVal Shift As Integer, _

ByVal X As Single, ByVal Y As Single)


x0 = X

y0 = Y


End Sub

Private Sub Label1_MouseMove(ByVal Button As Integer, _

ByVal Shift As Integer, _

ByVal X As Single, ByVal Y As Single)


Dim x1 As Long, y1 As Long


If Button = 1 Then

x1 = Label1.Left + X - x0

If x1 < 0 Then x1 = 0

If x1 Me.InsideWidth - Me.Label1.Width Then

x1 = Me.InsideWidth - Me.Label1.Width

End If


y1 = Label1.Top + Y - y0

If y1 < 0 Then y1 = 0

If y1 Me.InsideHeight - Me.Label1.Height Then

y1 = Me.InsideHeight - Me.Label1.Height

End If


Label1.Left = x1

Label1.Top = y1

End If


End Sub

'''''''''''''''''''''''''''

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services, Inc.
http://PeltierTech.com/WordPress/
_______


"Harald Staff" wrote in message
...
Hi Tony

Here on a Userform, dragging Label1 around:

Option Explicit ' *********** top pof module ************

Dim x0 As Long, y0 As Long

Private Sub Label1_MouseDown(ByVal Button As Integer, _
ByVal Shift As Integer, _
ByVal X As Single, ByVal Y As Single)
x0 = X
y0 = Y
End Sub

Private Sub Label1_MouseMove(ByVal Button As Integer, _
ByVal Shift As Integer, _
ByVal X As Single, ByVal Y As Single)
If Button = 1 Then
Label1.Top = Label1.Top + Y - y0
Label1.Left = Label1.Left + X - x0
End If
End Sub

HTH. Best wishes Harald

"Tony" wrote in message
...
Is there a way to allow a user to move (drag and drop) a text box or a
label on an open form? I want the user to be able to place a "note" on
the form, but once the box opens, I need them to be able to move it
around on the page similar to the way one can move a Post It note. I am
running Excel 2003.

Tony




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Concatenate to form a label gwendalee Excel Discussion (Misc queries) 3 October 16th 07 12:59 AM
Hyperlink on a label in a VB Form Gaetan Excel Discussion (Misc queries) 4 May 28th 07 12:35 PM
Form label not showing Les Stout[_2_] Excel Programming 0 October 17th 06 11:00 AM
COPY LABEL FORM FROM EXCEL TO A LABEL xrayAndi New Users to Excel 1 March 5th 06 02:21 PM
Disable Label in a Form Stuart[_21_] Excel Programming 4 March 13th 05 11:04 PM


All times are GMT +1. The time now is 11:14 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"