VC 6.0 MACRO:

CopyWord - macro to copy word under cursor to clipboard


This is a handy macro to copy word under cursor to clipboard. I'm using Alt-Ins hotkey by analogy to general purpose Ctrl-Ins function.

This seems to be quite simple task, but the major problem is the tabs and this macro works fine with tabs.

Sub CopyWord()
Set sel = ActiveDocument.Selection
sel.WordRight
end_i = sel.CurrentColumn
sel.WordLeft
begin_i = sel.CurrentColumn
sel.SelectLine
line_text = UnTab(sel.Text)
if begin_i > end_i then exit sub
word = Trim(mid(line_text,begin_i,end_i-begin_i))
if word = "" then exit sub
sel.MoveTo sel.CurrentLine,begin_i
sel.FindText(word) 'to select text in editor
sel.copy
End Sub

 


HOME