Monday, February 27, 2017

Excel 2013 error; [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

Based on your description, your Windows system is 64-bit and your Office is 32-bit.

I suggest you refer to this support article first:
https://msdn.microsoft.com/en-us/library/ms712362(v=vs.85).aspx

As the article said: To manage a data source that connects to a 32-bit driver under 64-bit platform, use :\windows\sysWOW64\odbcad32.exe.
To manage a data source that connects to a 64-bit driver, use :\windows\system32\odbcad32.exe.

Make sure that you create your ODBC link using the 32 bits ODBC Manager: C:\Windows\SysWOW64\odbcad32.exe
Source...

Saturday, February 04, 2017

VBA Excel - Using CreateObject

There are some very useful libaries that are not part of Excel VBA.
These include the Dictionary, Database objects, Outlook VBA objects, Word VBA objects and so on.

These are written using COM interfaces.
The beauty of COM is that was can easily use these libraries in our projects.

If we add a reference to the library we create the object in the normal way.

' Select Tools->References and place a check
' beside "Microsoft Scripting Runtime"
Dim dict As New Scripting.Dictionary

If we don’t use a reference we can create the object at run time using CreateObject.

Dim dict As Object
Set dict = CreateObject("Scripting.Dictionary")

The first method is referred to as Early Binding and the second is referred to as Late Binding(see Early versus Late Binding) for more details.

http://excelmacromastery.com/vba-objects/#Subtle_Differences_of_Dim_Versus_Set