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

Creating Add-Ins and COM Add-Ins

                             Option  Explicit
                             Public  ExcelApp  As  Excel.Application

                             Private  Sub  AddinInstance_OnAddInsUpdate(custom()  As  Variant)
                             ‘Called  when  an  add-in  is  changed

                             End  Sub
                             Private  Sub  AddinInstance_OnBeginShutdown(custom()  As  Variant)

                             ‘Called  when  Excel  is  in  the  process  of  shutting  down
                             End  Sub

                             Private  Sub  AddinInstance_OnConnection(ByVal  Application  As  Object,  _
                                 ByVal  ConnectMode  As  AddInDesignerObjects.ext_ConnectMode,  _
                                 ByVal  AddInInst  As  Object,  custom()  As  Variant)

                             Set  ExcelApp  =  Application
                             End  Sub

                             Private  Sub  AddinInstance_OnDisconnection(  _
                                 ByVal  RemoveMode  As  AddInDesignerObjects.ext_DisconnectMode,  _
                                 custom()  As  Variant)

                             Set  ExcelApp  =  Nothing
                             End  Sub

                             Private  Sub  AddinInstance_OnStartupComplete(custom()  As  Variant)
                             ‘Called  when  Excel  is  ready  to  use

                             End  Sub
                             Public  Function  DiscountedPrice(ListPrice,  Discount)  As  Currency
                                                                                                             Chapter 11
                             If  Discount  <=  1  And  Discount  >=  0  Then
                                 DiscountedPrice  =  ListPrice  *  (1  - Discount)
                             Else
                                 DiscountedPrice  =  0
                             End  If

                             End  Function







                                                                                                       251
                                                                                                Part 4:  Advanced VBA
   272   273   274   275   276   277   278   279   280   281   282