CopyToClipboard Method

Applies To

OraDynaset Object


Copy the rows from the dynaset to the clipboard in text format.


OraDynaset.CopyToClipboard(NumOfRows, colsep, rowsep)


The arguments for the method are:

Arguments Description
NumOfRows Number of rows to be copied to the dynaset
colsep [optional] Column separator in the CHAR data type to be inserted between columns
rowsep [optional] Row separator in the CHAR data type to be inserted between rows


This method is used to help transfer data between the Oracle Object for OLE cache (dynaset) and Windows applications, such as Excel or Word. The CopyToClipboard method copies data starting from the current position of the dynaset up to the last row.

The default column separator is TAB (ASCII 9).

The default row separator is ENTER (ASCII 13).


The following example copies data from the dynaset to the clipboard. Paste this code into the definition section of a form, then press F5.

Sub Form_Load ()
 'Declare variables
 Dim OraSession As OraSession 
 Dim OraDatabase As OraDatabase 
 Dim OraDynaset As OraDynaset 
 'Create the OraSession Object.
 Set OraSession = CreateObject("OracleInProcServer.XOraSession")
 'Create the OraDatabase Object by opening a connection to Oracle.
 Set OraDatabase = OraSession.OpenDatabase("ExampleDb", "scott/tiger", 0&)
 Set OraDynaset = OraDatabase.CreateDynaset("select * from emp", 0&) 
'Now call CopyToClipboard to copy the entire dynaset
 OraDynaset.CopyToClipboard -1, chr(9), chr(13)
End Sub