Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: Export Data to MS Excel in VBA - any DoCmd.TransferSpreadsheet in

20 views
Skip to first unread message

Paul Clement

unread,
Nov 23, 2005, 9:01:19 AM11/23/05
to
On Tue, 22 Nov 2005 19:16:07 -0800, "mimi" <mi...@discussions.microsoft.com> wrote:

¤ Hi,
¤ Please help!
¤ I'm trying to export data from MS SQL in Visual Basic project.
¤ Is there any similar command as in MS Access - DoCmd.TransferSpreadsheet -
¤ that can do the action to export to Excel spreadsheet? Or any method can be
¤ used in VB?

How about using SQL?

Dim cnn As New ADODB.Connection
Dim strSQL As String

cnn.Open _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=e:\My Documents\Book200.xls;Extended Properties=Excel 8.0;"

strSQL = "SELECT * INTO [Orders] FROM [Orders] IN '' [ODBC;Driver={SQL
Server};Server=(local);Database=Northwind;Trusted_Connection=yes];"

cnn.Execute strSQL

cnn.Close
Set cnn = Nothing


Paul
~~~~
Microsoft MVP (Visual Basic)

0 new messages