- Код: Выделить всё
Option Explicit
Dim db As Database
Dim rs As Recordset
Dim objExcel As Excel.Application
Private Sub cmdZakaz_Click()
Dim i As Integer
Screen.MousePointer = vbHourglass
Set db = OpenDatabase(App.Path & "\base.mdb")
Set rs = db.OpenRecordset("SELECT * FROM [Zakaz] ")
Set objExcel = New Excel.Application
objExcel.Workbooks.Open ("c:\1.xls")
With objExcel '.ActiveWorkbook.ActiveSheet
.Range("C16").CopyFromRecordset rs
.Range("B16:G" & rs.RecordCount + 15).Borders.LineStyle = 1
.Range("D16:D" & rs.RecordCount + 15).HorizontalAlignment = xlHAlignCenter
End With
EndInvoice rs.RecordCount + 16
objExcel.ActiveWorkbook.Save
objExcel.ActiveWorkbook.Close
objExcel.Quit
Set objExcel = Nothing
db.Close
End Sub
Sub EndInvoice(endline As Integer)
With objExcel
.Cells(endline, 6).Value = ""
.Cells(endline, 6).Font.Bold = True
.Cells(endline, 6).Font.Size = 10
.Cells(endline, 6).HorizontalAlignment = xlHAlignRight
.Cells(endline + 1, 6).Value = ""
.Cells(endline + 1, 6).Font.Bold = True
.Cells(endline + 1, 6).Font.Size = 10
.Cells(endline + 1, 6).HorizontalAlignment = xlHAlignRight
End With
End Sub
Не выгружается из памяти excel... в чем проблема?