How to Register Controls:

Before you can use an ActiveX control within the office suit of applications you must register it.
This tip explains how to register ActiveX controls in Microsoft Excel by using the WSHKit.dll as an example. Once you register an ActiveX control, you can use it in any Office application as well as in other Microsoft development products such as Visual Basic®.
The WSHKit dll is the Windows Script Host library. Once you've registered this, you will not need to issue the calls to regsvr32.exe, although this technique is still necessary for a more selective installation.
The WSHKit control will be used latter as an example code for the Browse function.

TIP:  To determining if an Exe or DLL is Self Registering
        Right click it, select Properties, Version.  Look for the OLESelfRegister entry.

There are a couple of ways to register the controls.
1) Using Regserv
2) Using Excel


1) Using Regserv:

You can use the Regsvr32 tool (Regsvr32.exe) to register and unregister
object linking and embedding (OLE) controls such as dynamic-link
library (DLL) or ActiveX Controls (OCX) files that are self-registerable.

Windows Taskbar
Click > Start
       > Run
          Type in > Regsvr32 WSHKit.Dll

If not successfull here then try explicitly
setting the paths eg.

C\Windows\System\Regsvr32 C:\Windows\System\WSHKit.Dll

Regsvr32.exe is included with Microsoft Internet Explorer 3.0 or later,
Windows 95 OEM Service Release 2 (OSR2) or later,
and Windows NT 4.0 Service Pack 5 (SP5) or later.
Regsvr32.exe is installed in the System (Windows Me/98/95) or System32 (Windows NT) folder.

Regsvr32.exe Usage
RegSvr32.exe has the following command-line options:
Regsvr32 [/u] [/n] [/i[:cmdline]] dllname

  /u - Unregister server<BR/>
  /i - Call DllInstall passing it an optional [cmdline];
       when used with /u calls dll uninstall
  /n - do not call DllRegisterServer; this option must
       be used with /i

When you use Regsvr32.exe, it attempts to load the component and call its DLLSelfRegister function. If this attempt is successful, Regsvr32.exe displays a dialog indicating success. If the attempt is unsuccessful, Regsvr32.exe returns an error message, which may include a Win32 error code. For a list of Win32 error codes, refer to the following Microsoft Web site:

http://msdn.microsoft.com/library/en-us/netdir/adsi/win32_error_codes.asp

For example, to manually register a Sample.ocx ActiveX control,
type the following command at an MS-DOS prompt:

c:\regsvr32.exe sample.ocx

2) Using Excel

My prefered way to register a control;
Use Excel > How

Look for the Control > More Controls
Available from your Toolbox Control commanbar. (See below)



















Clicking on this gives you the options of selecting a control to nsert in your sheet. We will NOT be inserting it. We will be looking for the Register Custom control command. (See Below)






















Clicking on this command gives you the Browse command box. (See Below)
Just browse for the control you wish to Register and select this.

Thats IT !   Very easy AND you now have the control available for ALL Office Applications to use.
This includes ActiveX (Obviously) on sheets or Userforms or within VBA Code.



Please check back soon, when I have updated what will be going in here!


1) Register Controls

2) Clean Projects and Why

3) What's up - classes & things

4) Having start-up troubles in Excel
HOW TO
Ivan F Moala
Tell a friend about this page
This page was last updated on: April 25, 2006
You are visitor number:
Can Do
Visits here
Clean VBA Projects and Why:


When creating VBA programs, a lot of "Garbage" builds up in your project files . If these files aren't cleared out
you will may begin to experience problems caused by this extra "Garbage". I have also found that this can be a problem when using VBA prgms developed via international versions of Excel.
eg Japanese Versions. To clean out your projects
Download the VBA cleaner program here:

http://www.appspro.com/utilities/Cleaner.asp

Also See more of an explaination here:

http://archive.baarns.com/excel/develop/vbaperfm.asp

Internally there are a number? of different compilation levels between decompiled and fully compiled.
As you work on your code (change / add / remove / recompile projects ) your opcodes may become "dirty", you will decompile the project, but recompiling Module1 does not remove all the "compiled" info about Module2
or UserForm1, for example.

Basically your code is stored in two forms, each one of which is a Stream object in the project's storage(s).
One form is the text form that you see while editing your code, the other is the compiled version of the code that runs. VBA must always compile before it runs.
Any time VBA thinks that the compiled code is invalid such as when you make a change or the binary format changes, which is so far only during Excodes (Platform-dependent VBA codes Stored after module is compiled) , it will "decompile" the module and then compile it again from the text. The text is never what is corrupted, it is always
some compiled portion of a project, like a module or most commonly the typeinfo of a Userform or Module code.
which is why the Addin basically Exports the code out.

While your @ it you may also want to clean your PC to do this see here for a concise way to do this;
My thanks to Anne Troy (Dreamboat) for this concise method.

http://www.thewordexpert.com/cleanyourpc.htm


Goto Guest book sign in page [Home]
Google
Search WWW Search My Site!