Background:
1) The Visual BASIC editor resides in Excel, Word, Visio or other Microsoft Office
products are called Visual Basic for Applications (VBA). They are not the same as the real
Visual BASIC, especially when you use VBA with ActiveX controls
2) When an ActiveX control, such as UltimaSerial, is added to a VBA program,
VBA creates a copy of its type library in a file with an .exd extension. This file is used
to merge the type information of the control with that of a host-provided extender object,
which "helps" to give the control added functionality while running inside the
VBA-enabled application.
Reality:
"It helps VBA program to interface with the control faster". It sounds good,
right? But unfortunately, this very feature kills the portability of ActiveX application
with VBA --- Thanks to Microsoft. Read on:
Scenario:
You wrote a VBA program in a Microsoft Office product, like Excel. Everything runs
fine. One day, you notice a newer version of ActiveX control on the web for download. So
you install the newer one, all the sudden, your program stops working any more! To make
things more confusing, a regular Visual BASIC program using the very
same ActiveX works just fine! What the heck ... you might say.
Solution:
When the ActiveX control used by an VBA application needs to be upgraded (not those minor bug-fixing upgrade, but a major one with new properties
and/or methods, etc.), the .exd files that were created when controls were added
must be deleted. In addition to deleting the .exd files themselves, extra steps must be
taken also. If you don't, the VBA program may not run properly anymore. "But wait!
why doesn't it happen to real VB program then?" you may ask. The real VB doesn't use
pre-constructed type library to interface with ActiveX and save all these headache.
In my opinion, use VB whenever possible! Here you can learn how to
send data to Excel directly from a VB program.
Steps I preferred during the ActiveX upgrade:
1) Download and install the new ActiveX control
2) Open the VBA program under VB editor of the Microsoft Office products
3) Remember the name of the ActiveX control then remove it from both the form and the
component panel
4) Save the codes (At this point, the VBA program will not run any more) and close the
Microsoft Office product
5) Use the Start->Find->Files or Folders... to locate all the ActiveX.exd on the
harddrives (not only the C: drive). In my case, ultimaserial*.exd. Delete them all.
6) Open the VBA program under VB editor of the Microsoft Office products again
7) Add the ActiveX control to the component panel
8) Add the control to the form, make sure it has the same name as the one you deleted
in Step 3) so that you don't need to change the codes
9) Save the file
Now you should be able to run it again!
Last update: 02/24/12
Copyright: 2000-2005
www.UltimaSerial.com
|