     7.     ActiveX	153 

     7.       ActiveX 

       ()     
 -       
 ActiveX.  ActiveX    (, .exe, 
.dll, .ocx),   ,   .  
       Visual Basic.  
ActiveX        
 . 
       , ,      
  ,     
  ActiveX     
Microsoft   .     
     ActiveX   . 
          ,   ,  
 ActiveX- ,    
Visual Basic.      ,    
   -'   .	~" ~ 

    7.1.    

        -  
    ,  ; 
     ,    
   .      . 
-,     ( 7~. 
-,         
    . 
               
   .   
 ,   , ,  
           
   .      
     : 
        ,    
 .   ,  
  .exe, .dll  ..    
   ;   , 
 ^^^^ .    , 
     -  . 
     -   
.
         ,     
.    ,      . 
        ,    
     . 
       ,      
     . 
      .  
         
 ( ). 


    154	  ! 

     -     
)     ,    
  .    ,  
    .  
  -'      
.    (   ),   
-   . 

    7.1.1.    

            
/  ,      , 
    .    ,  
 - ,   , , 
        . 
 Microsoft       OLE.  
  OLE        
 ,  DDE (Dynamic Data Exchange  -- 
 ).  OLE 1     "5  . DDE    
     Windows.  DDE  
  . DDE     ._? 
jorpjjByflHp  __,   .   
 -"  ,    . 
      .    ,  ,  
     DDE.    OLE    
&-^  DDE.  OLE   ,  
  '1  OLE; ^1" ,    COM. OLJE 
  .-=1. "      
. ,       OLE,   
  . 
       ,   OLE     
 . - .  OLE    
         
   ,    .  OLE 
       .  
 ,  -     . , , 
 OLE    !';' 
             .  
 ;  : C++    ,    
,       -->   .   
,   ,   ^   ., 
     .     C++. 
     Visual Basic. 

    7.1.2.   

            
 .      ,   
,      .   
 ,       
     .    
         
.    ,      
 ,   (. . 7.1.). 
            
 ,  .     
 ,        
.  ,       
   . 


     7.     ActiveX 155 


      
      
     		  
     		 D 

    . 7.1.       
  . 

        ,   ,  
     .  
      .   
-;   ,    
 ,  ,      
.      ,  
         . 
               
       .  
      . 

      
     		  
    
    
     		  I  D| 
    
    
    . 7.2.    ,  . 


    7.1.3.    

             
  .       
     ,       
   .    
 ,         , 
    . 
    ,   ,     
Paint  Photo Shop.  . 7.3  1  , 
  Paint,      2  Photo 
Shop.          
  . 

     1 
     2 
     	^	   
    
     		 D 
    |              Paint            | 
    : -*8 
     1  		  
     		 D 
    
    |        Photo Shop      | 

    . 7.3.      . 


    156   Modem 


    7.1.4.   

             
 .         
    ,   . 

      
      
    1 

    . 7.4.      ,   
    . 

            
     .   
      ActiveX,           
    OLE,   "   ".|   Visual Basic, , C++ 
 Java      ActiveX  
     Web-.   , , 
     - 
        =  . 

    7.1.5.   

             
  ,   ,    
,        
   .      
 /,     :    
 . 
          
,      . 
-,      ,   
  . -,    ,  
    ,     
     . 
    ,  . 7.5     D    
  .         
:     D.     
           D. 
      ,    
 . ,      
   .    , 
       ,    . 


     7.     ActiveX     157 


      
    1  		,.,  ._...,,   
    
    
     		 D 
    
    
      
      1 

    . 7.5.     . 


    7.1.6.    

           
      .  
       . 
-,      . 
-,    ( )   
. ,     ,   
    .     .  
   :     
  ,        
 .       . 

    7.1.7.   

            
,   ,      
 .        , 
        
  .    ,   
        
 .     ,   ,  , 
 , He^pj^as^gc^bjj^e^yjjy^roj^M^Qi^jo^ ,  
 ,   11^|^^^/]_    
  ,   . 

    7.1.8.  

        ?   
     .    
   ,       
   .        
,    ,    , 
     .     
 ,       . 
       , 
   ,   ,  , 
   . 
     ,      ,    
.   ,    , 
 .      .  
    ,      
. ,      , 
   . ,     ,  
  ,      . 


    158         

    ,     , 
   ^    .   
 .  ,   '  
,      .    
   ,    ,   
     (  .  
  ,        
   . 
            
  : 
    1.    _,    
.        
   OTjcoMnbioTepHoro ,    
   """ ^5~6   
   ,< .      
   /      
   :       
   . 
    2.      .    
 -   ,     
,      . 
    3.         
        ,    
  -.	"... ..---.., -._ 
           ,  
  . ,  . 7.6   
 ^  D   ,   . 

      
       	I	          ;,   | 
    
    
      		  D 
      
    2    		   
      		  D 

    . 7.6.         
  . 

           
.         
 >       . 
    4.        ()  
 .   ,   ,  
  !/ ,         
.          
,     .    
  ,   ,   
  ,       
  . 


     7.     ActiveX 159 


    7.1.9.   

           .   
    ""     , 
  ,      .  
   : 
    	   ^; 
    	    ,  ; 
    	  ^^_,     . 
        ,    
  . 
      ^      
 4eJ3e_3j^ji|2ajme,^3a^oQ6?a^ej^^UHM (    
). ,   ,  
   ,  _ .  
  . 
        : 
       -        
 ; 
         ,  , ,  ; 
            ,    
       . 
           . 

    7.1.10.   

       ,    , 
       .  
       ( 
),   . ,     
    ,    
   . ,    , 
  . 
       ,      
  . 

    . 7.7.       . 

      ^_ ,     
     . 


    160   , 

               
!    ,    
 -|         . 

      

    . 7.8.    . 

     /Unknown 
           
 : 
               
.     ,     
 ; 
               
,    .	"" 
            , 
 IDnknown.  lUnknown     
.        
  (Unknown. 

      lUnknown 

     (Unknown     AddRef, Release  Querylnterface. 
 AddRef  Release      , a 
Querylnterface     , 
 . 
     AddRef,   ,   
 .  Release  ,  , 
       . 
    AddRef ,       
 Set. Release ,      
Nothing       .  . 
    (      
 ),   . 
         Set . 
,   " ". 


     7.     ActiveX 161 


       

        ,    
  ,    Querylnterface    
  ,  . Visual Basic 
       Set. 
          
    .   "   ". 

    7.1.11.     

         ^  
^   ,    
-  , '  . 
      ,     
  ,      (Registry)   . 
         in-process 
             
         in-process 
(DLL)  out-of-process (. ).
        ,in-process  
    .     
         , 
    . 

        'out-of-process 

          out-of-process  
 ,    in-process,      
  .        
   ; 
        -   - 
  (proxy),        
.  1<"51"~-    , 
         , 
 . 
            
.         
     .  ,    
   ^~\      . 
              
      . 

    . 7.9.      . 

    6 .   136 


    162	  

          ,    
        
  (bCE-RPC).   -  
  Windows 95 Windows NT, UNIX  Macintosh,    
,  DCE-RPC 

    COM, GUID    

         public     
     (GUID).  GUID  
128-  _   , 
  . 
         ,    
  .   ,   
HKEY_CLASSES_ROOT  ,     . 
    (ProgID),  
     (ClasslD),    
  . 
      -,     
, --     ^  
,    .     (  
)        . 
       ,   
-,     . ,   
" "  " :  ". 

    7.2.   

     (    OLE-)   
 ,       
.        ,   , 
  _ ,       
   -. 
        ,   IDispatch. 
       ,  
.       ,  
  IDispatch. 

    7.2.1.   

         ,   
-      . 
       , ,  ,    
.     public    Property. 
            . , 
    ,   Addltem . 
          .   
   " "  "   
  ". 

    7.2.2.   

           , 
    .    
     :    DLL;    . 
;    


     7.     ActiveX 163 

           .  
    ,    
 : 
    	 ,  ; 
    	 ,   ,  ; 
    	        ; 
    	       ; 
    	     ,        . 
         ,      
.          
HKEY_CLASSES_ROOT  .
           .  .dll , 
  ,    aj^gjbJjJll_:tlb.   
   Visual Basic,     
 . 

      Object Browser 

    Object Browser ,      
  . 

     . 1.7    ,    Projectl. 

     / ,      Object Browser 
   Projectl    ,   
 ,   Projectl: Class'1  Form'1.    
 ,  Class'1    (gsUser  User)    
(ShowDate  Squarelt). 

    7.2.3.   

         ,     
         
  .      ,    
 .   ,   
   . 
         ,   
.       ,  
,     .    
 . 
          , 
  Microsoft Excel. 


    . 7.10.   Microsoft Excel. 


    164   

      -     
_.."w  (,     
   ;   .       
   ( /-_>:   New   CreateObject 
 VisuaiBasicX   ; :;      
. ,  Application  Microsoft Excel'. ,:- ,   
      Range  . 
      ,    , .  
 "^  "  8 "   ActiveX". 

    7.2.4.  IDispatch 

     , IDispatch,    
, :.-,.;sa-       
 .  :---%    : 
GetTypelnfoCount, GetTypelnfo, GetlDsOfNames  Invoke 
     GetTypelnfoCount  GetTypelnfo     
   ,   ,   . 
    GetlDsOfNames      /   
-'-.-   (dispID),    
. Invoke ^;."jt,       
  -   . 
        ,   IDispatch,  
 -- ,  : 

    IDispatch 
    I	AddRef 
    Release 
    Querylnterface 
    GetTypelnfoCount 
    GetTypelnfo 
    GetlDsOfNames 
    Invoke 

    . 7.11.  Idispatch. 

    IDispatch    : 
           ; 
              ,   
  (dispID); 
              . 
    .^^^^^, IDispatch    
  lUnknown. 

     . 7.12 ,    IDispatch: 

       IDispatch  dispID .   
"  "  " ". 


     7.     ActiveX 165 


    . 7.12.   IDispatch. 

    7.2.5.   

     IDispatch   ,   
,    IDispatch,   
  .      IDispatch  
   ^    GetlDsOfNames    Invoke 
(. "  "). 
     Invoke  ,     ,  
   .      
 .      . 
        ,    
  IDispatch.     , 
  Idispatch,        
 ,   .    
-         . 
       ,     . 
    IDispatch        
,   . 

     IDispatch 

      

    AddRef 
    Release 
    Querylnterface 
    GetTypelnfoCount 
    GetTypelnfo 
    GetlDsOfNames 
    Invoke 
    Property1_Get(...) 
    Property2_L8t(...) 
    Method1(...) 
    Method2(...) 

    . 7.13.  . 


    166	  

          ,   
 ,     IDispatch,  
Methodl  Method2   Invoke. 
      ,    Visual Basic 5.0,  
  ,   Methodl  Method2.   
   ,    vtable,  
   . ] 

    7.2.6.    

           ,    
  .  ,      . 
            ,  
 -   . 
              
;   ,    :   . 

      

       ,       
  . 
       ,       
     .      
GetlDsOfNames  IDispatch,       
 .      Invoke,  
  . 

      

      ,   ,  Visual Basic  
   ,       . 
            ,   
   ,     
,         . 
             
    . J3ja    
    :  dispID   vtable. 
    '$a 

    ^"  dispID 

      dispID    dispID  
        Invoke   
 dispID. ,     ,   
 ,     GetlDsOfNames. 

     vtable 

            vtable. 
 vtable     ,      
   GetlDsOfNames  Invoke. 
    Visual Basic    -   .  
          
  ( )     (vtable). 
          vtable  . 
  -       , 


     7.     ActiveX 167 

    Visual Basic     viable.  
  vtable      in-process 
 Visual Basic   -   , 
    DLL. 
           
  .   "  "  
" ". 

    7.3.    

      -  ,  
           
 .        
"'''" '  . 

    7.3.1.   Instancing 

     ,     Instancing,  
,        
-        . 
           Instancing: 

       () 

Private.       
 1            ,      
  .  Private    
.    ActiveX EXE, ActiveX DLL, ActiveX 
Control  Standard EXE. 

PublicNotCreatable.    
   ,       
 .        
    CreateObject   New.   
   Instancing,     
.     ActiveX E XE, ActiveX DLL  
ActiveX Control. SingleUse.       
. 3             ,   , 
   .     
ActiveXTEXE. 

GlobalSingleUse.   SingleUse,   
,  4               ,    
   .     ActiveX 
"". 

MultiUse.       . 
        
,   ,   ,    
.     ActiveX EXE  ActiveX DLL. 

GlobalMultiUse.   MultiUse,   ,   
    ,       6          
.      ,  
     .     ActiveX 
EXE  ActiveX DLL. 


    168    


    	    

    				ActiveX 	Exe	ActiveXDLL	ActiveXContol	Standard h 

    Private			X		X	X		X         --   I 
    PublicNotCreatable	X		X	X 
    SingleUse		X			=4 
    GlobalSingleUse	X 
    MultiUse		X		X		 1 
    GlobalMultiUse	X		X		 

     Instancing  Visual Basic 5.0     
:  Public  Visual Basic 4.0. 
       ,      
;     : 
          CreateObject: 

    Set   Instancel   =  CreateObject ("Projectl.Classl") 

         Dim   (  ,   
Public -1   True): 

    Dim   Instancel   As   New  Classl 

      New ,  Instancel     
  Classl. 
      Public  False,   Instancing . 
   !<'  ,   
.   Public  True,   , ,   
 ,     . 
      ._ -     
,     Instancing     
  ,      
 ,    . 

    7.3.2.     

             
    . 
    ,   , ,   
    ,     ,  
    ,   
   | '- ,   
  . 
       ^|__ :     
, ] ,   ,   
-,    .     
     : 


     7.     ActiveX 169 

          Instancing,  Visual Basic   
-    .    
    ,    
         
 . 
       out-of-process     
,      ,  
 . 
    ,        , 
  ,      
 , ,  ,  . 

    7.3.3.   

       ,     ,   
     .  Visual Basic  
   :    Visual Basic  
  . 
              
,     . ,   
  ,   ,      
 ,     ,   
  . 
       Visual Basic,       
,    ^^  ,  
  ?\^~~~\'" .  
   ,      
   ,     . 

          

 in-process       
(DLL).        (),   
-.   in~procsss    
    ,       
      DLL.   out-of-process  
              
.       ,    Qtf                      
       (). 
    out-of-process   
 ,       
-  ,        . 
     out-of-process,     
 .         
  ,    
,     -6ojrKy^jHa,   
.        . 
,          
,    . 


    170    Visual Basic 

              

    . 7.14.      . 

              
_- ,     . 
       ,    
  <    , .   " 
   "  "    
 ". 

    7.4.    Visual Basic 

       ,         
   . 
           ,  
Visual Baste, Microsoft Visual  ++  Microsoft Visual J ++. Visual Basic  
          
     
      -  Visual Basic   
 : 
    1.      . 
    2.   . 
    3.  . 
    4.     . 

    7.4.1.  :   

      -     
.           
     .  : "" "	-..-...~-..
    1.   Project  References. 
    2.    References   ,   
,  Ҹ   (. 7^5)!      
,  ,   ,   Browse,  
 . 
          , ~ Object 
Browser     , , , , 
  ,  . 


     7.     ActiveX 171 

         .   
" ". 

    . 7.15.   References. 

    7.4.2.  :    

        ,   
   . 
            
 (As ObjectJ,   ,    ,  
        
 . 

    :         
,     . 

       

             . 
     Variant.    Variant 
  "66  ,  ,    
    . 
            Object,  
   :

    Dim  x  As   Object 

             
   .   ,    
 ,      '   . 
          , 
     Visual Basic  . 

        

            
         . 


    172	   Visual Basic 

    ,     ,    
    Microsoft Excel Application. 

    Dim  ex  As   Excel.Application 

             
.     ,  Visual 
Basic        . 
,     .   
    Visual Basic   
,      . 
            
 ,  Visual Basic        
   -.     , 
Visual Basic         , 
       . 

    7.4.3.  :   

       -      
  ,        
 . 
       Visual Basic   : 
    	 CreateObject; 
    	 Set    New; 
    	 As New   Declaration ; 
    	 GetObject. 
           .   
   ,        
 ,     Visual Basic.   
   ,       : 
        ( ) ; 
              . 
             

      CreateObject 

      ,      , 
   , CreateObject    
  . 
       CreateObject : 

    Dim  objObjectl  As   Projectl.Classl 
    Set   objObjectl   =  CreateObject ( "Projectl.Classl") 


       New   Set 

          New  ,   
  ,   . 
         CreateObject    New  
  . ,    New   
 ,    , Visual Basic  
     . 


     7.     ActiveX	173 

            
: 

    Dim objObjectl As Project! .Classl Set objObjectl = New Project! .Classl 

     ,     , .   
"  Microsoft Excel". 

    :      nejDamop_Sef, 
     .   ,   
   ,     , 
    .  Set , ,  
   ,   AddRef. 
     ,   
,     Release     
  . 

       AddRef  Release .   
" ". 

      As New   Declaration 

        As New   : 

    Dim objObjectl as New Classl 

      As New     
     ,       . 
        As New,     
   . ,    : 

    Dim  ObjectVariablel   As   New  Classl If   Fund ()    Then 
    ObjectVariablel.Propl   =   5 End   if ObjectVariablel.Prop2   =   6 
    Visual Basic  ,   '   : 
    Dim  ObjectVariablel   As   New  Classl If  Fund ()   Then If  Not   
IsObject(ObjectVariablel)	'      
    Set   ObjectVariablel   =  New  Classl	' ' End   if                        
    '       
    ObjectVariablel.Propl   =  5 End  if If  Not   IsObject(ObjectVariablel)	' 
      
    Set   ObjectVariablel   =  New  Classl 
    End  if	'       ObjectVariablel.Prop2   =   6 
    New  CreateObject? 

            
     New   CreateObject. 
,    ,    
.  CreateObject      
  ,      Set  = New Y  Dim x As New Y 
      . 


    174	   Visual  

      CreateObject,       
     .     ProgID 
  ( Excel.Application)    ClasslD. 
        ClasslD   CIslD     
   . , CIslD     
  :  . 
            
  ,        
^ '         
 CreateObject. 
      ,     New,   
  ( _),      
  CIslD    (,   
)         . 
     ,        
CreateObjec    New. 

      GetObject 

         GetObject   ,  
    ,      
.      Workbook ( ) 
Microsoft Excel      Finances.xls: 

    Dim  xl  As   Object 
    Set   xl   =   GetObject(":\excel\finances.xls") 

         -   , 
Visual Basic  ,  ,   
  .xls. 
    GetObject     ,   
  / , ,     ,  
   . 

    7.4.4.  :    

             
     .   
       ,   
"" (.),    . 
          Automation,   
     : 

    .[\ 


       

          .  
    ,    
   . 
            
        , 
   . 
    , ,    ,  Speller, 
  : Check  IManage. Check   , 
  


     7.     ActiveX	175 

          . IManage 
       .    
    : 

    Dim  check  as   Speller.Check Dim mng  as   IManage 
    Set   check  =  New   Speller.Check   '	        
    "^-     	 
    Set  mng   = -heck   '	      IManage 
    '     	     2 

    7.5.     

    Visual Basic  5.0      
 :    .     
 .      
.   " ". 
           
   -,  ,   , 
  .     - 
   ' . 
         ,       
.       
  . 
       ,        
 ,    ,     
     . 

    7.5.1.     	'/ 

             
,        . 
   -   /     ,   
  . 
         ,    
   ,     
    . 
            
Visual Basic.       
  WithEvents,     : 

    Public  WithEvents   obj   As   Server.Object 

             
-,     : 

    Private   Sub   obj_Eventl() 
    '        Eventl End Sub 
    Private Sub obj_Event2(vNewValue As Variant) 
    '        Event2 End Sub 


    176	    

    7.5.2.  ,    

          ,   
,          . 
           ,  
    Implements,    Visual Basic 5.0. 
        
,    ,    
  .	~ 

    :       
 (    ,   )   
ActiveX DLL  EXE Visual Basic    K^njjn^m^a^icrosoft Interface^ 
Definition Language (MIDL),     Tools Visual Basic.	" 

      Visual C++   , , 
  MIDL.  BASIC, ,   
,    Visual Basic. 

       Implements 

           
    . 
         Object Browser   
 .        
 Implements    . 
    , ,     ISomelnterface 
  Method 1  Method2.    ,   
     : 

    Implements   ISomelnterface   '   
    Public  Sub  ISomelnterfaceJxiethodl () 
    '          Methodl End  Sub 
    Public   Sub   ISomeInterface_Method2() 
    '          Method2 End  Sub 

        

       ,     
,  ,       
  . 
          : 
         ,     
   ; 
        public (  ,     
),        ,  
 . 
          ,  
-     : 
    1. ,      .  
Visual Basic      . 


     7.     ActiveX	177 

    2. BjTg^o^eHj^HKTMeHT   ,    
  __ Implements,     
  ,   . 
    3.     ,     
       . 
    4.  ,     ,   
       . 
    5.   (    )  
 ,       
      ,   
 . 
         Cnotifyee    INotifyProc: 

    Option  Explicit 

    Implements   INotifyProc   '   ,       
    Public   Sub   INotifyProc_SleepEntered() MsgBox   "    
" End  Sub 
    Public   Sub   INotifyProc_SleepEnded() 
    MsgBox   "     " End  Sub 

       ,     
,         
 : 

    Option  Explicit 
    '             (   ) Dim  
objNotifyee  As   Notifyee         '"""" '      - Dim 
 objNotifier  As   CNotifier 
    Private   Sub   Form_Load() 
    Set objNotifier = New CNotifier 
    Set objNotifyee = New Notifyee 
    '   .^^ ^^ 0'^ -^ 
    orTjNotTfTer . Not if yProc = objNotifyee        -       ,;. .. End Sub 
    Private Sub cmdExit_Click() 
    Unload Me End Sub 
    Private Sub cmdSleep_Click() 
    objNotifier.Interval = txtlnterval 
    objNotifier.Wait '       End Sub 


    7.5.3.    ? 

        ,    ,  
     . 
             , 
    ,        
 .        
  


    178	   , 

-,         
    . 
           . 
     ,     ,  , 
  ,       
WithEvents. ,    ,    ,  
     ,    " "  
 . 
      , ,     
,      ,   . 
  ,     . 
    ,  ,   -   
,   -  . 
      , ,   ,   
    -   . 
,      . 
       ,     
     . 
      , ,   ,  
    . 
        ByRef,      
,   .     
   ,      
,      . 
      , ,     
,    ,    ByRef  
  ,         
 . 
           , , 
  ,     . 
      , ,     
   ,      
 ,       . 
     , ,    ,  
,  ,  : 
    	   ; 
    	      ; 
    	        ; 
    	       ByRef; 
    	    . 
          ,     
,    . 
        ,   
    .    
  ,  ,     ,   
 ,    viable.      
   In-process. 


     7.     ActiveX	179 


    7.6.  -,  Microsoft Excel 

       ,   Visual Basic   
-,  Microsoft Excel.     
,  Microsoft Excel,  , : 
               Microsoft Excel; 
            Microsoft Excel  
      ; 
               
 -; 
         Microsoft Excel; 
        ,    Visual Basic Macro 
Recorder,   Microsoft Excel.

    7.6.1.   Microsoft Excel 

    Microsoft Excel     ,  
   Visual Basic.      
  Microsoft Excel,     . 
         Microsoft Excel   . 
7.10.
     Visual Basic     New   CreateObject 
   Application, Chart  Sheet.     
 Microsoft Excel   ,   ,  
 Add. 

    :         
  1_. ,  Cells  Worksheet 
Microsoft Excel   Range. 

           
  (.). ,      1  
  Sheet'1    BOOK1.XLS: 

    xl.Workbooks("BOOK1.XLS").Worksheets ("SHEET1")_ .Range("Al").Value  =   5 

        ,      
 ,    Parent ,    : 

    xlwb.Parent   '          Application 

            
  . 
           xlsheet  
   Sheet'1    Book1.xls: 

    Dim  xl   as   Excel.Application 
    Dim  xlSheet   as   Excel.Worksheet 
    Set   xl   =  CreateObject("Excel.Application") 
    Set   xlSheet   =   xl.Workbooks ("BOOK1.XLS") .Worksheets("SHEET1") 
    xlSheet.Range("Al").Value   =   5 

            .    
     Book1.xls,  ,  
,  : 

    set   xlwb  =  xl.Workbooks("BOOK1.XLS") 


    180	 -,  Microsoft Excel 

        ,,  1.    
        Workbooks: 

    set xlwb = xl.Workbooks(1) 

    7.6.2.   Microsoft Excel 

            Visual Basic 
       . 
,     i    Microsoft Excel,  
 References ( Project | References)     
 Microsoft Excel 8.0 Object Library. 
            Microsoft 
Excel     New Visual Basic   
CreateObject  GetObject.      
  New   CreateObject .   " ". 

       New 

      New     Microsoft Excel. 
  Microsoft Excel    Excel.Application, 
Excel.Worksheet  Excel.Chart   ,    
 : 

    Dim  xl   as   Excel.Application Dim  xlchart   as   Excel.Chart Dim  
xlsheet   as   Excel.Worksheet 
    set   xl   =  New  Excel.Application set   xlchart   =  New  Excel.Chart 
set   xlsheet   =  New  Excel.Worksheet 

      GetObject 

        Microsoft Excel, ___ 
,   GetObject.	r ~~ " " 
     GetObject   .       
,    .    ,  
  .    ,   . 
       , GetObject    
 /  Microsoft Excel.  Microsoft Excel  , 
GetObject  . . 
          , GetObject    
   . 

    :     Microsoft Excel,   
)  .   ,    
True  Visible  Application.      
 . 


       

            Microsoft Excel  
     ,    
 . 
         Application    
   , Microsoft Excel   . 
    Quit  Application. 


     7.     ActiveX	181 


    7.6.3.   Microsoft Excel 

    ,   Microsoft Excel,      
.         Microsoft 
Excel Workbook   . 
        ,       
   Workbooks.      
Workbooks    : 

    xl.Workbooks.Add   () 

         : 

    xl.Workbooks.Open   "c:\bookl.xls   " 

              
 : 

    Dim  xl   as   Excel.Application 
    Dim  xlwb   as   Excel.WorkBook 
    On  Error  Resume  Next 
    set   xl   =  CreateObject("Excel.Application") 
    set   xlwb  =  xl.Workbooks.Open   ("c:\bookl.xls") 
    If  Err   <>   0   Then 
    Msgbox   "         " 
    Unload Me EndTf        "~~ 

       ,    For...Each  
     Workbooks,  ,  
   : 

    For  each  xlwb   in  xl.WorkBooks 
    if  xlwb.Name   =   "Bookl.xls"   Then bookfound =  True Exit   For End   
If Next   xlwb 

           Close  Workbook.  
 ,     ,    
SaveChanges,        
   . 
          : 

    xl.ActiveWorkbook.Close   SaveChanges   :=   False    
  Bookl .xls 
    xl.Workbooks ("BOOKl.XLS") .Close   SaveChanges   :=False 

    7.6.4.     

             Range 
 Worksheet.        
  ,  1,    . 
          Sheet'1.  
   1     range"!: 


    182	 -,  Microsoft Excel; 

    set xlsheet = _     
    xlapp.Workbooks ("Bookl") .Worksheets ("Sheetl") xlsheet.Range("Al").Value 
= 5 xlsheet.Range("rangel").Value = 10 

     Range   Range.  Range     
       : 

    set xl = CreateObject("Excel.Application") 
    '     
    xl.Workbooks("x.xls").Worksheets("s").Range("Al").Value = 5 
    '        xl .'Range ("A2") .Value = 5 
    '    Set wb = xl.Workbooks("source.xls") Set 
ws = wb.Worksheets("sheetl") Set rg = ws.Range("Al") rg.Value = 5 

      

            .  
    Microsoft Excel    
        .   
   ,   Microsoft Excel  
 : 

    Dim  x(l   to   4,    1   to   2)   As   Integer 
    x(l,l)   =   5 
    x(l,2)   =  5 
    x(l,3)   =   6 
    ....'               
    xl.Range("Al:B4").Value   =     '             

       _   Variant   
Variant : 

    '          
    varl   =  xl.Range("Al:B4").Value 
    MsgBox  v(l,l)    '   Variant      

           ,   For...Each: 

    Dim  r   as   Range 
    For each r in xl.Range("summary") '   
    r.value = 25 Next r 


    7.6.5.   Charts 

             
Microsoft Excel.  ,     , 
  Charts Microsoft Excel.       
Microsoft Excel         : 

    xlsheet.Range("Al:D4").Select 
    set  xlc  =  xl.Charts.Add() 
    xlc.Type   =  xlSDColumn   '       -   - 

              
 : 


     7.     ActiveX 183 


    set   xlc  =xl.workbooks("bkl.xls").Charts("mycht") xlc.Type   =   x!3DColumn 

       ( ClickQ  cmdCreateChart)  
Microsoft Excel,          
  : 

    Sub   cmdCreateChart_Click() 
    Dim  xl   As   Excel.Application 
    Dim  xlc  As   Excel.Chart 
    Set   xl   =   CreateObject("Excel.Application") 
    xl.Visible   =   True 
    xl.Workbooks.Add 
    xl.Range("Al").Value   =   3 
    xl.Range("A2").Value   =   2 
    xl.Range("A3").Value  =   6 
    xl.Range("A4").Value   =   4 
    xl.Range("A5").Value   =   8 '    ...              
    xl.Range("Al:A5").Select 
    Set  xlc   =  xl.Charts.Add() 
    xlc.Type   =  x!3DColumn End  Sub 
    X Microsoft Excel - 2 

    . 7.16.    Microsoft Excel  Visual Basic. 


    184	 -,  Microsoft Excel 

    7.6.6.   Microsoft Excel 

      Microsoft Excel  ,    
 ~;   Visual Basic.     Run 
 Application. 
    , ,   Microsoft Excel   : 

    Sub ChangeNumbers () 
    For Each x In Worksheets("Sheetl").Range("Al:D10") x.Value = Rnd() * 100 
    Next x End Sub 
         Visual Basic: 
    Private Sub Commandl_Click() 
    set xl = CreateObject ("Excel.Application") 
    xl.Workbooks.Open ("c:\bookl.xls") 
    xl.Run "ChangeNumbers" End Sub 

       Microsoft Excel,   : 

    '        Function MakeProper 
(MyString As String) As String 
    MakeProper = Application.Proper (MyString) End Function 
        Visual Basic: 
    Private Sub Commandl_Click() 
    s = xl.Run ("MakeProper", " Microsoft excel") 
    '  s    " Microsoft Excel" 
    End Sub 


     Microsoft Excel Macro Recorder 

      Visual Basic    Microsoft 
Excel,     Microsoft Excel,     
  ^ Visual Basic. 
           Visual Basic    
Microsoft Exc Macro Recorder.      
  Microsoft    Visual Basic. 
    ,    ,     
_  . ,  Visual Basic    
 Microsoft Exce      New. 
      Visual Basic    , 
    Microsoft Excel. 
       ,  Microsoft Excel Macro Recorder: 

    Sub  Macrol 
    ActiveWorkbook.SaveAs Filename:="TERMPAPR.XLS", FileFormat:=xlNormal,_ 
Password:="", WriteResPassword:="", _ ReadOnlyRecommended:=False , CreateBackup:=False 
    End Sub 

        ,   Visual Basic: 


     7.     ActiveX 185 

    f. 
    Dim xl As Excel .Application~<v ..-.,> 
    Set xl = New Excel.Application^ 
    ,xl_^Workbooks -Acid   _...._,.....-__-^ 
    xl.ActiveWorkbook.SaveAs Filename:="TERMPAPR.XLS", FileFormat:=xlNormal,_ 
    Password:="", WriteResPassword:="", _ ReadOnlyRecommended:=False , CreateBackup:=False 


    7.6.7. :  Microsoft Excel 

             
Microsoft Excel.         
 : 

    7	^J	= ! 7 
    				D           | .	.        ! 
    4 
    5 .._ 
    7 
        
    9 
    10" 
     
    12 
    13 
    14 
    15 
    16 
    |   1	   1995       1996		 
    19971 
    ._ ________ 0|  	1 759 050 431 250	1 91 7 365 448 500	2 
089 927 466 440 
     [ 	1 327800 118125	1 468 865 1 22 850	1 623 487 127764 
     (  |	77800 315000	80912 327600	84148 340 704 
    ) )	1 2 670 523595	13177 544539	1 3 704 566 320 
      	304 205	924 326	1 057 167 

    . 7.17.    Microsoft Excel. 


      

    1.    Visual Basic. 
    2.   : ii  Excel 
        
      
    |,||.   Excel 
       

    . 7.18.     Excel. 


    186	 -,  Microsoft Excel 

         Microsoft Excel 
    1.       Microsoft Excel 5.0 Object Library. 
    2.     ,     xl 
 x(Chari: 

    Dim  xl  As   Excel.Application Dim xlc  As  Excel.Chart 

    3.     Click  "  Excel", 
  CreateObject,    Microsoft Excel 
Application     ,    . 
  .   "  Microsoft Excel". 
    4.     Visible Microsoft Excel  True. 
    5.   Open Microsoft Excel,    Market.xls. 
   Click(): 

    Private   Sub  cmdCreateXLObject_Click()    '      "    
Ex'-   " set   xl   =   CreateObject("Excel.Application") xl.Workbooks.Open  
App.Path   &   "c:\office\Market.xls" xl.Visible   =   True 
    End  Sub 

    6.  . 

       Microsoft Excel 
    1.     Click   " " 
   ""     " " 
(Growth)  " " (Inflation)     
" " (txtGrowth)  " " (txtlnflation) . 
       : 

    Private   Sub   cmdEstimate^Click()    '      "   " xl.Worksheets("").Activate 
    xl.Worksheets("").Range("Growth").Value   =   
txtGrowth.-xl.Worksheets("").Range("Inflation").Value   -  _ txtlnflation.Text 
    End   Sub 

    2.  : 

        ; 
         "  Excel",   Microsoft Excel 
   ; 
         Visual Basic,       
   " ". 
      
    1.     Click  "",   
xJCharl  ,   Nothing,   Select, 
 -^   " " (Net_Profit)   "". 
    2.   Add  Chart,      
  -J   xlChart. 
    3.      Chart  xlSDColumn.   
 i    Microsoft Excel. 


    :/  7.     ActiveX 187 

    ! 
      
    4.   xlChart    Nothing,   
 Activate,     . 
      : 

    Private   Sub   cmdChart_Click()    '      "" If  xlc   Is  
Nothing  Then 
    xl.Worksheets("").Range("net_profit").Select set  xlc  =  
xl.Charts.Add() xlc. Type   =  xlSDColumn Else 
    xlc.Activate End   If End   Sub 

    5.  : 
        ; 
         "  Excel",   Microsoft Excel 
   ; 
         Visual Basic    "". 

    1 
     1 098 724 (33; 

    . 7.19.  Excel     . 

