Sub test()
On Error GoTo CloseRs
Dim conn As New ADODB.Connection
conn.connectionString = "Provider=OraOLEDB.Oracle;Data Source=xxxxxx;User Id=xxxxxx;Password=xxxxxx;"
conn.Open
Dim rs As Object
Dim tableListSheet As Excel.Worksheet
Dim i As Integer
Dim v_sql As String
v_sql = "SELECT * FROM test1"
Set rs = CreateObject("ADODB.Recordset")
rs.Open v_sql, conn
Worksheets("sheet1").Cells.Clear
Worksheets("sheet1").Range("A1").CopyFromRecordset rs
CloseRs:
If Not rs Is Nothing Then
rs.Close
conn.Close
End If
End Sub
On Error GoTo CloseRs
Dim conn As New ADODB.Connection
conn.connectionString = "Provider=OraOLEDB.Oracle;Data Source=xxxxxx;User Id=xxxxxx;Password=xxxxxx;"
conn.Open
Dim rs As Object
Dim tableListSheet As Excel.Worksheet
Dim i As Integer
Dim v_sql As String
v_sql = "SELECT * FROM test1"
Set rs = CreateObject("ADODB.Recordset")
rs.Open v_sql, conn
Worksheets("sheet1").Cells.Clear
Worksheets("sheet1").Range("A1").CopyFromRecordset rs
CloseRs:
If Not rs Is Nothing Then
rs.Close
conn.Close
End If
End Sub