Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Closing an Application

Status
Not open for further replies.

sgfromny

Technical User
Jan 17, 2003
120
US
Hi All,

I have this code in an access database form, Problem is each time i run it, it loads an instance of Excel in the background, Hence I can 10 Excels running at once.

How Do I remove the Current Instance of excel at the end of the code on my form?

Dim objXl As Excel.Application
Dim objWkb As Excel.Workbook
Dim objSht As Excel.Worksheet
Set objXl = New Excel.Application
With objXl
.Visible = False
Set objWkb = .Workbooks.Open("f:\forecast\proposal\" & Me.Proposal & ".xls")
.Range("Document").Value = "0" & Me.Job_Number & "J"
.Range("became").Value = Date
.Range("propno").Value = Me.Proposal
.Range("H4").Value = "PO" & Me.Customer_PO
objWkb.SaveAs ("f:\forecast\proposal\" & Me.Proposal & ".xls")
objWkb.PrintOut
objWkb.Close
End With
 
Hi sgfromny,

When you are done with it, add the line:

Code:
objXl.Quit

It would also be good practice to add

Code:
Set objSht = Nothing
Set objWkb = Nothing
Set objXl = Nothing

Enjoy,
Tony


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top