object disconnected

F

finalmoksha

Hi ppl,
I'm new to VBA. I have an excel application which I'm ssuppossed t
enhance. This application is called from a Vb application and i
references a dll which handles the login and logout procedures.

My problem is that the login happens smoothly (-- called i
workbook_open) but when we close the excel appilcation, the logou
function (--called in workbook_close) throws up an error saying

**************************************************
Run-time error '-2147417848(800010108)
Automation error
The object invoked has disconnected from its clients.

**************************************************

Also could you please tell me how to debug the code within the exce
workspace.. I invoke it using ALT + F11, but the debug does'nt work a
in VB.

Thanks in advanc
 
G

Guest

The (ActiveX) DLL is a binary file: you will not be able to view its contents
unless you have the source. So, it is no surprise that Alt+F11 does not show
the DLL code.

However, in the workbook_open event you will see something like:

set xxx = CreateObject(nameofdll.nameof classwithin)

or, if the DLL is explicitly referenced, perhaps:

Dim xxx as new nameofclasswithin

That your clue. In the workbook_close event, you might need to include one
or the other of these statements before invoking the method that logs out.

In any case, this is not really satisfactory as the DLL should not
evaporate. I order to investigate, you need the souorce code.
 
F

finalmoksha

i have the code for the dll, it is working fine with other application
made in VB. The code in Excel is as follows.
*************************************************
General Declaration
Dim Obj_C2Klogin As C2kLogin.clsLogin


Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Not Obj_C2Klogin Is Nothing Then
* Obj_C2Klogin.LogOut* the error occurs in this line
Set Obj_C2Klogin = Nothing
End If
End Sub


Private Sub Workbook_Open()
Set Obj_C2Klogin = New C2kLogin.clsLogin
Obj_C2Klogin.LogIn
End Su
 
G

Guest

You say that it works fine with other VB applications: is the login for a
data source?

What is the code in the subroutine LogOut in the class Login?
 
F

finalmoksha

the logout procedure calls a stored procedure on the SQL server.



Public Function LogOut() As Boolean
On Error GoTo err_handler
LogOut = False
If connected And p_Userid <> "" Then
Dim LogOffQy As rdoQuery, LogOffCmd As New ADODB.Command
If p_ConType = iRDO Then
If Not RDOCon Is Nothing Then
Set LogOffQy = RDOCon.CreateQuery("LogOffQuery", "")
LogOffQy.SQL = "{call sp_LogOff( ? , ? )}"
LogOffQy("@UserID") = p_Userid
LogOffQy("@AppIdent") = p_AppIdent
LogOffQy.Execute
If LogOffQy(0) = 0 Then LogOut = True
LogOffQy.Close
End If
Else
If Not ADOCon Is Nothing Then
LogOffCmd.ActiveConnection = ADOCon
LogOffCmd.CommandType = adCmdStoredProc
LogOffCmd.CommandText = "sp_LogOff"
LogOffCmd.Parameters.Refresh
LogOffCmd("@UserID") = p_Userid
LogOffQy("@AppIdent") = p_AppIdent
LogOffCmd.Execute
If LogOffCmd(0) Then LogOut = True
End If
End If
Set LogOffCmd = Nothing
connected = False
While colDBConfiguration.Count > 0
colDBConfiguration.Remove 1 ' Remov
all
Wend
End If
Exit Function
err_handler:
LogOut = False
End Functio
 
G

Guest

I can't see where the problem might be. My only guess is that you might need
DoEvents after the line:

LogOffCmd.Execute
 
F

finalmoksha

tried the Doevents...
Same problem still occurs.

Is there any way we can do a line by line debug in the exce
application usinf F8 as we do in the VB IDE. Is there any other way b
which we can check the lifetime of the dll object in the exce
application??

I see no problem with the dll itself because it is working perfectl
alright with other applications. All I need is a way to debug in th
excel environment. Please let me know if there is a way to d
it..Thanks for the help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top