Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word rectangle positions

Status
Not open for further replies.

tecnik

Programmer
Feb 16, 2006
22
GB
Hi there,

I have a simple macro that draws a rectangle on the page however I'd like to change the macro so it draws the rectangle at the cursor postition. Is this relatively easy to do.

Thanks in advance,

Nick


Here's the code:-

Code:
Sub box()
 ActiveDocument.Shapes.AddShape msoShapeRectangle, 50, 50, 100, 200
End Sub
 
direct from F1 search on mouse

The following example determines where the mouse is and whether the left mouse button and/or the SHIFT key is pressed. The x and y coordinates of the mouse pointer position are displayed in a label control as you move the mouse.

To try the example, add the following event procedure to a form that contains a label named Coordinates:

Private Sub Detail_MouseMove(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
Dim intShiftDown As Integer, intLeftButton As Integer

Me!Coordinates.Caption = X & ", " & Y
' Use bit masks to determine state of
' SHIFT key and left button.
intShiftDown = Shift And acShiftMask
intLeftButton = Button And acLeftButton
' Check that SHIFT key and left button
' are both pressed.
If intShiftDown And intLeftButton > 0 Then
MsgBox "Shift key and left mouse button were pressed."
End If
End Sub



--------------------
Procrastinate Now!
 
Thanks for the help with this one

I've tried adding a form element to a document and giving it a label 'Coordinates' and then adding the sub-routine to my macros code but I can't see it when I try to assign it to the form element.

When I look at the list of macros I can't see the new event procedure however I can see all the macros I've created.

Think I may be going wrong somewhere, can you help?

Thanks again,

Nick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top