Link to home
Start Free TrialLog in
Avatar of mpdillon
mpdillon

asked on

Late binding question

Currently, I have a VB6 ActiveX EXE which is located on a server. I have numerous progams that use this ActiveX EXE. I have used early binding in all these programs.
Whenever a change is made to the ActiveX EXE which breaks compatibility, I have to unregister than Re register the ActiveX EXE in all the projects. This happens a couple of times a year.
It is my understanding that with late binding this would not be necessary. Is this correct?
I tried to experiment with the late binding but was not able to create the object.

Dim objWP as Object

objWP = CreateObject("WPExe.exe","\\FileServer\Code")

This code failed.
I also tried
objWP = CreateObject("WPProject.Class1","\\FileServer\Code")
This also failed. I have never installed or registered the ActiveX EXE on the server(FileServer).

What would be the correct way to accomplish this.
Avatar of 23637269
23637269
Flag of United States of America image

Yes that is correct.
When you use early binding you can enjoy the text assist when coding.

To get the best of both worlds keep it bound while in development mode then when ready to compile a release uncheck the reference.

The way that I took care of updating multiple systems in the field was to create a standalone exe that would just start and check the update folder on the server to see if there are any updates.  If there were they would be copied down.  You can also run RegSvr to register any OCXs' or DLLs'.  After everything is updating the updater program would end and start the normal program exe.  The reason that end user shortcut starts the updater and not the normal exe is that you can't update the exe if it is running.

Thanks
Roger
Avatar of mpdillon
mpdillon

ASKER

Roger,
Thanks for confirming my belief that late binding would solve the registration prolem. However, I cannot get the ActiveX exe on th e Server to register on the server. Also I cannot get the Create Object code to run without error. Any insights on these two points?
If the EXE is running on the remote machine (and it has been set up to allow remote access) you only need to pass the machine name as the second argument.

The following snippet is taken from 'http://msdn2.microsoft.com/'. If you search there for 'CreateObject' you will find more details.

Sub CreateRemoteExcelObj()
   Dim xlApp As Object
   ' Replace string "\\MyServer" with name of the remote computer.
   xlApp = CreateObject("Excel.Application", "\\MyServer")
   MsgBox(xlApp.Version)
End Sub

Hope this helps.

Bill
Bill,
Sorry for the long delay in my response. I believe you are on the right track. Here is my code.
Dim objWP as object
objWP = CreateObject("WPProjectX.Class1,"\\MyServerName")

At this point I receive a "Run Time Error 91.  Object variable or With Block not set ."

I am trying to running this ActiveX exe application(WPProjectX) on a workstation. However, the actual exe(WPProject.exe) resides on MyServer. I looked in the registry on the server and found the following keys(?)
Implemented Categories
ProgID
Programmable
TypeLib

In the ProgID key was the default value "WPProjectX.Class1"

This ActiveX exe does not continuously run in the background. Rather, every time it is called by a workstation, a new instance is created on the workstation and then destroyed when the calling app closes.
This has worked fine for some time when I use early binding. But I would like to use late binding. This will make changes to the exe easier to implement and expand my knowledge of how VB works.
thanks again for any addtional help you might provide.
pat
Version
Set objWP = CreateObject("WPProjectX.Class1,"\\MyServerName")
Roger,
Thanks for your reply. I made the change by adding SET to my code. However, it still does not function. But I did get a new error message. That message is:

The remote server machine does not exist or is unavailable.

Any thoughts?
pat
ASKER CERTIFIED SOLUTION
Avatar of 23637269
23637269
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial