G
Guest
Hi
I am trying to use automation to create an Excel document and then write a recordset from an Access database into a worksheet. However, when I later attempt to close the document manually, it does not seem to close it properly. Instead, it appears to lurk in the background, tying up my system memory and preventing Windows from closing down or simply causing it to crash
Does anyone know of a way around this problem
I have only just began this project, however, I will list the code I have created so far
TIA
Private Sub cmdCreateAllocation_Click(
'Initialize and create heade
Dim Ex As New Excel.Applicatio
Dim WrkBk As Excel.Workboo
Dim Wks As Excel.Workshee
Dim Rng As Excel.Rang
Dim Rs As New ADODB.Recordse
Dim Col As ADODB.Fiel
Set WrkBk = Ex.Workbooks.Ad
Set Wks = WrkBk.Worksheets(1
Wks.Name = "Test1
Rs.Open "SELECT tblAllocStores.Store, " &
"tblAllocSociety.Society " &
"FROM tblAllocStores " &
"INNER JOIN tblAllocSociety " &
"ON tblAllocStores.SocietyID = " &
"tblAllocSociety.SocietyID", CurrentProject.Connectio
Set Rng = Wks.Cells(40, 1
Do Until Rs.EO
For Each Col In Rs.Field
With Rn
.Value = Col.Valu
End Wit
Set Rng = Rng.Offset(0, 1
Nex
Rs.MoveNex
Loo
Ex.Visible = Tru
End Su
I am trying to use automation to create an Excel document and then write a recordset from an Access database into a worksheet. However, when I later attempt to close the document manually, it does not seem to close it properly. Instead, it appears to lurk in the background, tying up my system memory and preventing Windows from closing down or simply causing it to crash
Does anyone know of a way around this problem
I have only just began this project, however, I will list the code I have created so far
TIA
Private Sub cmdCreateAllocation_Click(
'Initialize and create heade
Dim Ex As New Excel.Applicatio
Dim WrkBk As Excel.Workboo
Dim Wks As Excel.Workshee
Dim Rng As Excel.Rang
Dim Rs As New ADODB.Recordse
Dim Col As ADODB.Fiel
Set WrkBk = Ex.Workbooks.Ad
Set Wks = WrkBk.Worksheets(1
Wks.Name = "Test1
Rs.Open "SELECT tblAllocStores.Store, " &
"tblAllocSociety.Society " &
"FROM tblAllocStores " &
"INNER JOIN tblAllocSociety " &
"ON tblAllocStores.SocietyID = " &
"tblAllocSociety.SocietyID", CurrentProject.Connectio
Set Rng = Wks.Cells(40, 1
Do Until Rs.EO
For Each Col In Rs.Field
With Rn
.Value = Col.Valu
End Wit
Set Rng = Rng.Offset(0, 1
Nex
Rs.MoveNex
Loo
Ex.Visible = Tru
End Su