Jump to content

Small tool for copy coordinate to clipboard


maunaloa

Recommended Posts

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!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.

Disable-Adblock.png

 

If you enjoy our contents, support us by Disable ads Blocker or add GIS-area to your ads blocker whitelist