Re: CreateObject Function (VBA/Excel/2002-3)

Jan, my knowledge of VBA would be on a much higher level if I knew how to properly respond to your reply.

I do not know why early binding is indicated in the code I posted. Simply that I needed code to do something (create an object to allow me to send an XL sheet to a mail recipient) and that code was available after a brief search.

My posting was to alert others to the problem that surfaced on a client workstation and that was resolved by the addition of 'localhost' in the CreateObject function. Why? I do not have sufficeint experience to explain why.

Re: CreateObject Function (VBA/Excel/2002-3)

Early binding means that you set a reference to the relevant object library in Tools | References..., in this case to the Microsoft Outlook n.0 Object Library. You can then declare an object such as

Dim OutApp As Outlook.Application

Advantages of early binding:
- IntelliSense will kick in when you type OutApp followed by a point (period).
- You can perform a syntax check.
- You can use symbolic constants such as olMailItem, making your code more readably.
- Code execution will be more efficient.

Disadvantages of early binding:
- The reference may break if the user has a different version of Outlook (in particular an earlier version than you have) or if Outlook is installed in a different folder than on your PC.

Its counterpart is late binding, where you don't set a reference to the object library. You declare objects associated with the application as plain Objects:

Dim OutApp As Object

Advantages of late binding:
- The code will also work if the user has a different version of Outlook, or if Outlook is installed in another folder.

Disadvantages of late binding:
- You can't use IntelliSense.
- You can't check the syntax for application-specific issues.
- You cannot use symbolic constants such as olMailItem, you must use their value instead.
- Code execution will be less efficient.