Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Copy (TextSelection Object)
Cut
Run
Collapse the table of content
Expand the table of content

Copy Method (TextSelection Object)

Visual Studio .NET 2003

Copies the selected text to the clipboard.

[Visual Basic .NET]
Public Sub Copy() 
[Visual Basic 6]
Sub Copy() 
[C++]
HRESULT __stdcall Copy();
[C#]
public void Copy();
[JScript .NET]
public function Copy()

Example

Public objSel As TextSelection = DTE.ActiveDocument.Selection

Sub CopyExample()
   ' Before running this example, open a text document.
   ' Perform operations on the text.
   objSel.StartOfDocument(False)
   Position(vsStartOfLineOptions.vsStartOfLineOptionsFirstColumn, 4)
   objSel.Copy()
   Position(vsStartOfLineOptions.vsStartOfLineOptionsFirstText, 4)
   objSel.Cut()
   Position(vsStartOfLineOptions.vsStartOfLineOptionsFirstText, 4)
   objSel.Delete()
   Position(vsStartOfLineOptions.vsStartOfLineOptionsFirstText, 4)
   objSel.DeleteLeft(6)
   objSel.DestructiveInsert("NEW TEXT")
End Sub

Sub Position(ByVal pos As vsStartOfLineOptions, ByVal ipos As Integer)
   ' Moves the insertion point down to the beginning of the next line, 
   ' then highlights the right-most four characters.
   objSel.LineDown()
   objSel.StartOfLine(vsStartOfLineOptions.vsStartOfLineOptionsFirstText)
   objSel.CharRight(True, 4)
End Sub

See Also

Applies To: TextSelection Object

Show:
© 2015 Microsoft