將查詢結果導出到Excel的另一個方法

發表于:2007-07-01來源:作者:點擊數: 標簽:
Option Explicit Dim dbado As New ADODB.Connection Dim cmdado As New ADODB.Command Dim sqlstr As String Dim howdo As String Dim filename As String Private Sub command1_click() filename = App.Path "\" InputBox("輸入新文件名:", "保存") ".xls

Option Explicit
Dim dbado As New ADODB.Connection
Dim cmdado As New ADODB.Command
Dim sqlstr As String
Dim howdo As String
Dim filename As String

Private Sub command1_click()
filename = App.Path & "\" & InputBox("輸入新文件名:", "保存") & ".xls"
howdo = Text1.Text

dbado.Open ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path  & "\goods.mdb;Persist Security Info=False")


sqlstr = "SELECT * INTO [Excel 5.0;DATABASE=" & filename & "].[data] FROM [basic] where id in (" & howdo & ")"

dbado.Execute (sqlstr), , adCmdText + adExecuteNoRecords

dbado.close

end sub

 

 


原文轉自:http://www.anti-gravitydesign.com

国产97人人超碰caoprom_尤物国产在线一区手机播放_精品国产一区二区三_色天使久久综合给合久久97