So let’s see an easy example how to create a new Word document from Excel with Early binding: Sub createWordDocEarlyBinding()ĪppWord.Visible = True 'Add a new document It requires Word Object Library, without having it the below error message will pop-up: Open VBE editor -> ‘Tools’ menu -> Select ‘References’ -> Search for the desired Object Library -> Put a tick in the check box and click ‘Ok’ Adding Object Library reference manually via VBE -> Tools -> References Or if you have no information about the IT infrastructure you can go with the mixed solutions presented at the end of this article :). In case of the slightest chance that your code might be used on ‘unknown ‘ computer choose late binding. It makes your life easier during development, code is more readable. Usually it depends on the circumstances, if you are 100% sure that users are going to use your tool on a computer which has the same parameters as yours then go for early binding. It is really hard to tell if not impossible which approach to use. Both of them have their advantages and disadvantages, in the below table I collected the main ones (without attempting to be comprehensive, for more details simply search in Google): DescriptionĪt first look it seems that Early binding beats Late binding except in version dependency.
In VBA automation there are two types of binding early binding and late binding. For example sending an email via Outlook, export output to Word or PowerPoint, upload data to Access etc.Įach program has its own object model, in order to work with other application Excel has to create a link to the other application’s object library via binding. At some point you may run into a situation when your Excel tool needs to interact with other office application.