Export (0) Print
Expand All
Cut
Run
Expand Minimize

Copy Method

Visual Studio .NET 2003

Copies the specified range of text to the clipboard.

[Visual Basic .NET]
Public Sub Copy( _
   ByVal PointOrCount As Object, _
   Optional ByVal Append As Boolean = False _
) 
[Visual Basic 6]
Sub Copy( _
   ByVal PointOrCount As Variant, _
   Optional ByVal Append As Boolean = False _
) 
[C++]
HRESULT __stdcall Copy(
   VARIANT PointOrCount,
   VARIANT_BOOL Append
);
[C#]
public void Copy(
   object PointOrCount,
   bool Append
);
[JScript .NET]
public function Copy(
   PointOrCount : Object,
   Append : Boolean
)

Parameters

PointOrCount
Required. Either a TextPoint Object or a number of characters.
Append
Optional. Indicates whether to append the selected text to the clipboard. The default is False.

Remarks

If the argument is a TextPoint object, Copy copies a string representing the text between the edit point and PointOrCount. If the argument is an integer, then Copy copies a string representing the specified number of characters following the edit point (counting one for each implied newline sequence at the end of each line). If PointOrCount is negative, then Copy copies text before the edit point rather than after.

If Append is True, then Copy appends the selection to the current clipboard contents rather than replacing it.

Example

Sub CopyExample()
   Dim objTextDoc As TextDocument
   Dim objEditPt As EditPoint, iCtr As Integer
        
   'Create a new text file.
   DTE.ItemOperations.NewFile("General\Text File")
        
   'Get a handle to the new document and create an EditPoint.
   objTextDoc = DTE.ActiveDocument.Object("TextDocument")
   objEditPt = objTextDoc.StartPoint.CreateEditPoint
       
   'Insert ten lines of text.
   For iCtr = 1 To 10
      objeditpt.Insert("This is a test." & Chr(13))
   Next iCtr
        
   'Copies the fourth word of the fourth line and pastes it, 
   'then cuts the fourth word of the eighth line.
   objEditPt.StartOfDocument()
   objEditPt.LineDown(3)
   objEditPt.WordRight(3)
   objEditPt.Copy(4)
   objEditPt.Paste()
   objEditPt.LineDown(3)
   objEditPt.WordRight(3)
   objEditPt.Cut(4)
End Sub

See Also

Applies To: EditPoint Object

Show:
© 2015 Microsoft