Page 270 - Microsoft Office Excel 2003 Programming Inside Out
P. 270

Microsoft Office Excel 2003 Programming Inside Out

                    Using the AddIns Collection

                             The AddIns collection contains the set of add-ins available whether or not they have been
                             installed. The entries in this collection correspond to the add-ins listed in the Add-Ins dialog
                             box. Through the AddIns collection, you can browse the add-ins available to Excel, add new
                             add-ins, and install and remove add-ins from your program.


                    AddIns Collection
                             The AddIns collection is a typical collection object having the properties shown in Table 11-2.

                             Table 11-2.  Properties
                             Property      Type          Description
                             Application   Object        Returns the Application object representing the creator of
                                                         the add-in.
                             Count         Long          Returns the total number of AddIn objects in the
                                                         collection.
                             Creator       Long          Returns a 32-bit integer containing the binary value XCEL.
                             Item(Index)   String	       Returns the AddIn object associated with Index. If Index
                                                         is numeric, it refers to the relative position of the object
                                                         in the collection. If Index is a string, the Item property
                                                         returns an object reference to the AddIn object whose
                                                         Name property matches the value in Index.
                             Parent        Object        Returns the parent object associated with the add-in.
                             The AddIns collection includes a single method, Add. The Add method takes one or two
                             parameters and returns an object reference to the new AddIn object. The syntax of the Add
                             method as it applies to the AddIns object is
                             expression.Add(FileName,  CopyFile)

                             The FileName parameter is required and specifies the full path and file name of the add-in.
                             The CopyFile parameter is optional and applies only when the file is stored on a removable
                             drive (that is, a floppy or a CD-ROM drive). When the second parameter is True, the add-in
                             is copied to a hard disk, whereas False means that the file remains on the removable drive. If
             Chapter 11
                             the second parameter isn’t specified and the file resides on a removable drive, Excel will
                             prompt the user to choose whether the file should be copied or not.
                             This code fragment shows you how you can use the Add method to include a new add-in
                             workbook in the AddIns collection:

                             NewAddIn  =  Application.AddIns.Add("c:\Chapter11.xla")





                244
             Part 4:  Advanced VBA
   265   266   267   268   269   270   271   272   273   274   275