ACC2000: Applications Run from Automation Do Not Always CloseID: q210129
|
When you open other applications, such as other Microsoft Office 2000 programs, through Automation code, the applications that you open may not always close when your code finishes running.
Microsoft provides programming examples for illustration only, without warranty
either expressed or implied, including, but not limited to, the implied warranties of
merchantability and/or fitness for a particular purpose. This article assumes that you
are familiar with the programming language being demonstrated and the tools used to
create and debug procedures. Microsoft support professionals can help explain the functionality
of a particular procedure, but they will not modify these examples to provide added
functionality or construct procedures to meet your specific needs. If you have limited
programming experience, you may want to contact a Microsoft Certified Solution Provider
or the Microsoft fee-based consulting line at (800) 936-5200. For more information about
Microsoft Certified Solution Providers, please see the following page on the World Wide Web:
http://www.microsoft.com/mcsp/For more information about the support options available from Microsoft, please see the following page on the World Wide Web:
http://www.microsoft.com/support/supportnet/overview/overview.aspYou can use Automation code to open and manipulate other Microsoft Office programs. When you open a program by using Automation, an instance of the program is created in memory. If you don't close each instance of a program that you open, that instance may remain open but hidden. Each time that this happens, additional memory resources are consumed on you computer until you either restart the computer or shut down the hidden instances of the program manually. Having multiple, hidden instances of a program in memory can adversely affect the performance of your computer.
Function Automation_To_Excel()
Dim objExcel As Object
' Create a new instance of Excel.
Set objExcel = CreateObject("Excel.Application")
' Show the instance of Excel on the screen.
objExcel.Visible = True
' Open a file named SampleFile.xls
objExcel.Workbooks.Open ("C:\My Documents\SampleFile.xls")
' Explicitly close the instance of Excel to free up memory
' and set the variable to Nothing to free up the name
' space in Access.
objExcel.Quit
Set objExcel = Nothing
End Function
objExcel.[Quit]
When you convert a database that uses the Quit method in this fashion from Access 2.0 to Access 2000, you will need to manually remove the brackets from the Quit method. The brackets will not cause an error, but if they are present, the Quit method will not close the instance of the program being run.
Function Automation_To_Excel()
Dim objExcel As Object
' Create a new instance of Excel.
Set objExcel = CreateObject("Excel.Application")
' This sample will actually leave a hidden copy of Excel
' in your computer's memory. To leave an open copy of Excel
' on the task bar, remove the comment mark from the
' line below.
' objExcel.Visible = True
' Open a file named SampleFile.xls
objExcel.Workbooks.Open ("C:\My Documents\SampleFile.xls")
End Function
?Automation_To_Excel
For more information about programming with Automation, in the Visual Basic Editor, click
Microsoft Visual Basic Help on the Help menu, type "Understanding Automation" in
the Office Assistant or the Answer Wizard, and then click Search to
view the topic.
Additional query words: conversion issue OLE
Keywords : kbinterop kbole kbdta AccCon IntpOlea
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: July 6, 1999