maunaloa Posted January 19, 2012 Report Share Posted January 19, 2012 Aloha guys! I made a small script in Vba, for a simple work: click in ArcMap mapwindow, and copy the cursors coordinate to the clipboard. The main goal was that: create a simple button in ArcMap, and set the click event, to read the coordinate and put it on the clipboard in a specific format (formatted string). the code is this: 'this two variable will contain the coordinates from the active mapwindow, but they only integers, so the original coordinates will be cutted to integer values Dim x As Integer Dim y As Integer 'this string will contain the concatenated coordinate values, with a ";" sign Dim koord As String Dim pmxdoc As IMxDocument Dim ppoint As IPoint Public Sub minta_MouseDown(ByVal Button As Long, ByVal Shift As Long, ByVal x As Long, ByVal y As Long) Set xy = New DataObject Set pmxdoc = ThisDocument Set ppoint = pmxdoc.CurrentLocation x = ppoint.x y = ppoint.y 'this message box will drop a small message, it's a sign, show the read coordinates MsgBox "x: " & x & "; y: " & y, vbSystemModal 'the string variable will be the concatenated coordinates koord = x & "; " & y xy.SetText koord 'the string copied to the clipboard, now ready ta paste:) xy.PutInClipboard End Sub This small code was made by ArcObject book, a similar code read the coordinates of the mouse cursor, but i wrote some code to copy it to clipboard. This code was written to the Normal.mxt, so i can use it all projects. I made a button, tools menu > customize > new uicontrol button > new uitoolcontrol, and i selected a new icon for the button: don't close the customize window, click on new button by right mouse button, and select a new icon. Then right click > view source. You can copy the code to tha mousedown event. I thought, maybe anyone can use it:) Enjoy! Quote Link to comment Share on other sites More sharing options...
Administrators EmperoR Posted January 19, 2012 Administrators Report Share Posted January 19, 2012 nice, code should be block in CODE to make it different from text, we need more post like you maunaloa, +1 from me Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.