Problems with automation

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
 
R

RobFMS

Jedster

When you use automation to open excel, you should either allow the
automation to close it or you need to set the object variable to nothing (
Set objExcel = Nothing ).

--
Rob

FMS Professional Solutions Group
http://www.fmsinc.com/consulting

Software Tools for .NET, SQL Server, Visual Basic & Access
http://www.fmsinc.com

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Jedster said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top