FAQ>Run-time Assembly

Releasing automation objects

 

Article #:

0017

Contributor:

Daniel Todes

GF version:

3.05

Applies to:

Automation objects at run time

Last updated:

October 17, 2001

Question

How do I release an automation object when it is no longer being used in my template?

Answer

You can create an automation object at run time by using the CreateObject task. Store the reference (an IDispatch pointer) returned in a variable, and then you can control this object from FillPoints.

 

To release the object, simply reset the variable.

 

Click here to view a step-by-step example.

  1. The following FillPoint creates an Excel object and stores a reference to it in the ExcelServer variable:

%[ExcelServer=CreateObject('Excel.Application')]

  1. You can then open an Excel workbook:

%[ExcelServer.Workbooks.Open('c:\excel\workbook1.xls')]

And access the values in a specific spreadsheet:

%[ExcelServer.ActiveSheet.Cells(2,1).Value]

  1. To release the object, reset the variable:

%[ExcelServer='']

 

NOTE

If more than one variable references the same automation object, you need to reset each variable in order to release the automation object.