Sub TestHDRConnectParameter(blnHDRParam As Boolean)
Dim dbs As Database
Dim rst As Recordset
Dim strHDRParam As String
If blnHDRParam = True Then
strHDRParam = "YES"
Else
strHDRParam = "NO"
End If
' Open the Microsoft Jet sample database.
Set dbs = OpenDatabase("C:\JetBook\Samples\Excel\Products97.xls", _
False, False, "Excel 8.0HDR=" &strHDRParam &"")
' Create a Recordset object for the Microsoft Excel Products worksheet.
Set rst = dbs.OpenRecordset("Products$")
' Move to the last record and display the RecordCount property value.
With rst
.MoveLast
MsgBox "There are " &.RecordCount &" records in this worksheet."
.Close
End With
dbs.Close
End Sub
注意:
(1)HDR指定是否将首行作为标题行。
(2)表名字后面要加$符号。
office里有ACCESS数据库啊,如果习惯了使用EXCEL,可以使用EXCEL的VBA的宏命令来 *** 作ACCESS数据库,对于有大量数据需要统计的人员,ACCESS+EXCEL的结合,对工作的益处非常之大欢迎分享,转载请注明来源:内存溢出
评论列表(0条)