vb操作excel的问题!
Private Sub C_Click()
Dim adoCnnection As ADODB。Connection
Dim rsData As ADODB。Recordset
Dim sConnect As String
Dim sSQL As String
Dim sPath As String
sPath = ThisWorkbook。 Path
If Right$(sPath, 1) <> "\" Then sPath = sPath & "\"
'microsoft oledb
sConnect = "provider=Microsoft。 Jet。OLEDB。4。0;" &...全部
Private Sub C_Click()
Dim adoCnnection As ADODB。Connection
Dim rsData As ADODB。Recordset
Dim sConnect As String
Dim sSQL As String
Dim sPath As String
sPath = ThisWorkbook。
Path
If Right$(sPath, 1) <> "\" Then sPath = sPath & "\"
'microsoft oledb
sConnect = "provider=Microsoft。
Jet。OLEDB。4。0;" & _
"Data Source=" & sPath & "Plan。xls;" & _
"Extended Properties=Excel 8。
0;" & _
"Persist Security Info=False;Jet Password=253"
sSQL = "select * from [生产计划$Plan_Area] order by 机号 desc" ', 模具编号 desc"
Set adoCnnection = New ADODB。
Connection
adoCnnection。Open sConnect
Set rsData = New ADODB。Recordset
rsData。ActiveConnection = adoCnnection
rsData。
Open sSQL, sConnect, adOpenForwardOnly, adLockReadOnly, adCmdText
If Not rsData。EOF Then
生产计划。
Range("A1:AX600")。CopyFromRecordset rsData
Else
MsgBox "没有排序数据。", vbCritical
End If
rsData。Close
Set rsData = Nothing
End Sub。
收起