These three simple macros work together to add multiple clipboard functionality to Microsoft Visual C++. Along with macros in the macro file you will find a couple of global variables. The most important one is a buffer used to collect up to 5 selections. MCopy
adds the current selection to the end of the buffer. MPaste
pastes the last copied string to the document and makes it selected. If you then execute MPaste
again it takes another string from the buffer and replaces the previously pasted string. You can execute MPaste
as many times as you want until you decide which selection to keep. And finally MClear
resets the buffer. Enjoy!
Dim buffer(4)
Dim nCopy
nCopy = 0
Dim nPaste
nPaste = 0
Dim nBufferSize
nBufferSize = 0
Sub MCopy ()
if ActiveDocument Is Nothing Then
Exit Sub
elseif ActiveDocument.Type <> "Text" Then
Exit Sub
elseif Len(ActiveDocument.Selection) > 3060 Then
MsgBox("Too long selectection")
Exit Sub
elseif Len(ActiveDocument.Selection) = 0 Then
Exit Sub
End If
ActiveDocument.Selection.Copy
buffer(nCopy) = ActiveDocument.Selection
nPaste = nCopy
nCopy = nCopy + 1
if nCopy > 4 then
nCopy = 0
End If
if nBufferSize < 5 then
nBufferSize = nBufferSize + 1
end if
End Sub
Sub MPaste ()
if ActiveDocument Is Nothing Then
Exit Sub
elseif ActiveDocument.Type <> "Text" Then
Exit Sub
End If
if nBufferSize = 0 then
MsgBox("Empty buffer")
Exit Sub
End If
ActiveDocument.Selection = ""
Dim curCol
Dim curLine
curCol = ActiveDocument.Selection.CurrentColumn
curLine = ActiveDocument.Selection.CurrentLine
tempPasteStr = buffer(nPaste)
tempPasteStr = Replace(tempPasteStr, string(1, vbCr), "")
Dim pasteStrLen
pasteStrLen = Len(tempPasteStr)
ActiveDocument.Selection = buffer(nPaste)
if pasteStrLen < 400 then
ActiveDocument.Selection.MoveTo curLine, curCol
ActiveDocument.Selection.CharRight dsExtend, pasteStrLen
end if
nPaste = nPaste + 1
if nPaste >= nBufferSize then
nPaste = 0
End If
End Sub
Sub MClear ()
nCopy = 0
nPaste = 0
nBufferSize = 0
End Sub