吉林森工毛陈居审查:vb问题——数据库中内容打印

来源:百度文库 编辑:查人人中国名人网 时间:2024/05/02 21:42:15
Dim xlApp As Excel.Application
Dim xlBook As Workbook, xlSheet As Worksheet
Set xlApp = CreateObject("Excel.Application")
Set xlApp = New Excel.Application
xlApp.Visible = True
Set xlBook = xlApp.Workbooks.Open("d:\Temp.xls")
Set xlSheet = xlBook.Worksheets(1)
Set rs = db.OpenRecordset("home")
xlSheet.Cells(10, 8) = "rs!95年工龄"
xlSheet.PrintPreview
xlBook.Close
这个是一个打印预览的按钮,把数据库home中的内容导出到excel的模板里,但是总是提示错误
对象变量或者with块什么未定义的,是怎么回事啊?弄不明白,谢谢各位
不是把!我在form_load里面已经打开了数据哭了,

//Set rs = db.OpenRecordset("home")

rs 的好像没有定义。

没有和数据库进行连接,因此没有rs记录集。

Set xlSheet = xlBook.Worksheets(1)
这里的XLSHEET定义了吗?