Sie sind auf Seite 1von 4

Accessing CAA V5 Object from Scripting Languages

Objective:
This Article describes the methodology of creating a CAA V5 object that can be
accessed from scripting languages. The step by step procedure of creating a
CAA V5 object( in Visual Studio 2005 and accessing the same from V!A
(CAT"A is also presented.
Description:
# $or calling any CAA V5 object from simple scripting language %e need to
use automation interfaces. Automation "nterfaces are special interfaces that allo%
CAA V5 programming from simple scripting languages.
The CAA V5 "&' ("nterface &efinition 'anguage is the language used to %rite
automation interfaces.
The CAA V5 "&' ("nterface &efinition 'anguage is dedicated to create
programming language independent interfaces that %e can use from both a
compiled languages such as C(() and scripting languages such as Visual !asic
and *Script %ith +indo%s) and !asic Script %ith ,-"..
"&' pro/ides C0language li1e declarations that associate an identifier %ith a type.
The "&' compiler (2"&' builds the run time type library from "&' source files and
stores it in a shared library(Type 'ibrary or .tplib.
Scripting languages uses these type libraries (.tplib to access the type
information about the functions. Actual function implementation is a/ailable in a
&''.
The type library is a compiled /ersion of a set of "&' files. "t contains the
description of all the interfaces) all the method prototypes) properties) and all the
parameters they re3uire along %ith their types.
The base interface for e4posed interfaces that are used in scripting languages is
"&ispatch interface. "&ispatch interface deri/es from ",n1no%n interface.
Compared to C(() scripting languages ha/e parameter type support restrictions.
The compatible parameters of the method signatures are a/ailable in the CAA
5ncyclopedia at the follo%ing lin1.
CAA&oc6&oc6online6CAASysTechArticles6CAASysAutomation"tf.htm
Schematic &iagram sho%ing ho% a V!A application access CAA Component.
Steps for creating a sample CAA Application that can be
accessed from VBscrpit of CA!"A#$
Step %: Create a &e' (rame'or) for "DL "nterface creation in CAA*+AD,
7. $ile 8 -e% CAA V5 +or1space
Select the +or1space directory and Tool 'e/el.
2. "n -e% CAA V5 +or1space dialog ) select 9-e% :eneric frame%or1s;.
<. "n the -e% $rame%or1 dialog select =$rame%or1 type; as "nterface and select
9"&' Support; option.
>. Create an "nterface
:o to $ile8CAA V5 "tem 8 "nterface.
"n the "nsert "nterface dialog) ?ro/ide the "nterface name and Select language as
9 Automation "&';) Select @eader repository as 9?ublic"nterfaces;.
This module %ill generate .idl file.
+esolve the Common build error:
"f frame%or1 is not /isible in the solution e4plorer then close the %or1space) and
delete the Tools&ata $older in the %or1space and open the %or1space in the VC
again. And build the %or1space using m1m1.
After the build an error %ill be generated saying that 9unresol/ed type
declaration A AnyBbject C "nterface DTestD E;
Bpen the .2F file in the Type'ib.m module and delete A *S0:GB,? 6*S0$2
*S0:GB,? from the +"HAG&I'"-FI2B&,'5S.
Bpen the .tplib file from the same module and add the follo%ing macro in the
?rere3uisite type libs after Jpragma G5?G5K "nf!-peLib
Jpragma G5?G5K "nfType'ib in the LL ?rere3uisite type libs
Build the 'or) space using m)m)#
A Successful built %ill produce a Type'ibrary that corresponds to the "&' and a
&'' that corresponds to "nterface.
Step . : Create a &e' (rame'or) for "mplementation#
7. $ile8Add CAA V5 project 8 -e% $rame%or1.
Select $rame%or1 type as 9"mplementation; and complete the frame%or1
creation.
2. "nsert a ne% module in the abo/e $rame%or1
$ile8 Add CAA V5 projectM-e% 2odule.
<. "n -e% 2odule dialog select Shared Bbject option under the 2odule
"nformation options.
>. Add ne% "tem to the created 2odule.
$ile8Add CAA V5 "tem8Component.
N. "n the "nsert Component &ialog pro/ide the follo%ing information.
$or &eri/ed from option pro/ide 9 CAT!aseBbject 9.
"n the T"5 2ode option A&& the created "nterface.
"n the @eader Gepository select 9 ?ublic "nterfaces;.
!uild the +or1space) this generates a &'' (Shared 'ibrary that corresponds to
"mplementation 2odule.
Steps for using CAA Object in the CA!"A VBA Script#
7. Start the CAT"A Session and open the re3uired file.
2. Bpen V!A 5ditor by follo%ingA Tools8 2acro 8 Visual !asic 5ditor.
<. Add the Type 'ibrary (.tplib that %e created.
:o to Tools8Geferences and add the library by using !ro%se button.
7. Bpen a ne% 2odule and add the follo%ing lines of code after CAT2ain(
LL&eclare a Variable of type V! Bbject name) this V! object name is a/ailable in
the "&' file that %e created in Step 7.
7. &im (Variable -ame As (V! Bbject -ame
LL Set the Variable to the CAT"A Application.
2. Set (Variable -ame O :etBbject(PP) PCAT"A.ApplicationP
LL Call the 2ethod or $unction in the interface
<. Call (Variable -ame . (2ethod -ame.

,/ample code:
&im CAT"AT,TBGBbj As &ra%ing$actory
Set CAT"AT,TBGBbj O :etBbject(PP) PCAT"A.ApplicationP
Call CAT"AT,TBGBbj.2y$unction(Q

Das könnte Ihnen auch gefallen