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

Microsoft Office Excel 2003 Programming Inside Out

                             You probably noticed that while this code was executed, you received a warning similar to the
                             one in Figure 21-4. The security against viruses has increased dramatically since the release of
                             Office XP. The trend has continued with the release of Office 2003. Any attempt by programs
                             trying to access e-mail addresses will execute a warning message. You’ll also receive a warning
                             each time an e-mail message is sent using VBA code.













                             Figure 21-4.  Warning message you get when executing code that interrogates your Contacts
                             folder in Outlook.


                             Inside Out

                             Early Binding vs. Late Binding
             Chapter 21
                             Both early binding and late binding have advantages and disadvantages. Late binding is
                             slower than early binding because the binding occurs during run time. When you complete
                             the work in design time, the code will run faster. When you are writing code using late bind­
                             ing, you lose some conveniences. Specifically, you aren’t able to use the IntelliSense that
                             displays the available properties and methods available for the objects that you’re using.
                             The Object Browser also won’t list the objects for the application objects that you’re pro­
                             gramming. Another disadvantage is that the convenience of built-in constants isn’t avail-
                             able when using late binding.
                             It would appear that a strong case has been made to use early binding; however, there’s
                             one strong advantage to late binding that shouldn’t be overlooked. When late binding is
                             used, it doesn’t matter which version of the application is installed. The application object
                             will search for the version installed on your system and choose the correct object mode to
                             reference. In early binding, you’ll choose the application’s Object Library from the Refer­
                             ences list. The References list will contain only installed object libraries. If you choose to
                             share your procedure with others, the list will be coded specifically to the version of the
                             software that’s installed on your system.

                             The moral of the story is to write your code initially using early binding, but before distribut­
                             ing the file you should modify the code to use late binding. It would be a good idea to modify
                             your personal projects to late binding as well, so a problem won’t arise when your software
                             is upgraded in the future.






                454
             Part 6:  Excel and the Outside World: Collaborating Made Easy
   475   476   477   478   479   480   481   482   483   484   485