|
楼主 |
发表于 2013-12-30 20:44
|
显示全部楼层
nhygm 发表于 2013-12-30 18:59
赵老师:我运行你给的例子,可以运行,但是数据不更新,我把这个程序加到我建的工作薄里,提示“找不到可 ... - Sub 导出打印记录()
- Dim cnn As Object, SQL$, SQL1$, sh As Worksheet
- Set cnn = CreateObject("ADODB.Connection")
- cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties='Excel 8.0;hdr=no';Data Source=" & ThisWorkbook.FullName
- SQL = "Select * From [原始数据$] Where F3 = '" & Range("G7") & "'"
- SQL1 = "update [原始数据$] set F10 ='已打印' where F3 = '" & Range("G7") & "'"
- 'cnn.Execute ("update [原始数据$] set [原始数据$].f10 = '123456' ")
- On Error Resume Next
- Set sh = Sheets("打印数据")
- If Not sh Is Nothing Then
- sh.Cells.Clear
- Else
- Sheets.Add.Name = "打印数据"
- End If
- Sheets("打印日志").Range("a65536").End(xlUp).Offset(1, 0).CopyFromRecordset cnn.Execute(SQL)
- Sheets("打印数据").Range("A1").CopyFromRecordset cnn.Execute(SQL)
- cnn.Execute (SQL1)
- cnn.Close
- Set cnn = Nothing
- ActiveSheet.PrintOut
- End Sub
复制代码 |
|