Board index » delphi » COM-Server in D5 problem?

COM-Server in D5 problem?

Hi,
I am writing a Com Server in D5. The ComServer should be called ba MS Word
with VBA.
I have created the Comserver in D5 with a new Automation Object and then I
call the Comserver in VBA with following code (VBA):
  sub myServer
      Set objComserver = CreateObject("Application.myComserver")
      objComserver.Function1("Test")
  end sub

My comserver will be started but will also be closed immediately wenn VBA is
after "End Sub".

My wish is:
ComServer will be started ba VBA and the comserver will become some
information from VBA and use the information in the comserver. At the end
the user will use comserver, cancel the connection with the Client and close
the comserver from themself.

How can I do it in D5?

Thanks for your help.

Daniel

 

Re:COM-Server in D5 problem?


Quote
>   sub myServer
>       Set objComserver = CreateObject("Application.myComserver")
>       objComserver.Function1("Test")
>   end sub

> My comserver will be started but will also be closed immediately wenn VBA
is
> after "End Sub".

Ok course it does... That's your punishment for not declaring variables with
the dim...
Just kidding (partially).
The objects gets out of scope at the end of your sub if you don't declare
objComserver outside that mathod call.
The reference counting of COM disposes it.

Re:COM-Server in D5 problem?


As Alessandro said your problem is that you are declaring and calling your COM
object in a subroutine/function ( I don't know VB terminology).  Anyway, in D5 I
usually declare the object that is my COM in the forms private or public section
(depending on how it is to be used) and then make my connection to it in the
forms OnCreate event and disconnect on the forms OnClose or OnDestroy event.  I
would attempt something similar in VB.  Hope this helps.

Jeff

Quote
Daniel Zhou wrote:
> Hi,
> I am writing a Com Server in D5. The ComServer should be called ba MS Word
> with VBA.
> I have created the Comserver in D5 with a new Automation Object and then I
> call the Comserver in VBA with following code (VBA):
>   sub myServer
>       Set objComserver = CreateObject("Application.myComserver")
>       objComserver.Function1("Test")
>   end sub

> My comserver will be started but will also be closed immediately wenn VBA is
> after "End Sub".

> My wish is:

> ComServer will be started ba VBA and the comserver will become some
> information from VBA and use the information in the comserver. At the end
> the user will use comserver, cancel the connection with the Client and close
> the comserver from themself.

> How can I do it in D5?

> Thanks for your help.

> Daniel

--
Jeff Alexander
Unitime Systems, Inc.
jalexan...@unitime.com

Re:COM-Server in D5 problem?


Quote
> Ok course it does... That's your punishment for not declaring variables
with
> the dim...
> Just kidding (partially).
> The objects gets out of scope at the end of your sub if you don't declare
> objComserver outside that mathod call.
> The reference counting of COM disposes it.

Hi,
I don't think so. I have declared a global variable objComserver with DIM,
but the same problem.
Must I give some parameters in D5, when I create a COM Server or?

Thanks,

Daniel

Re:COM-Server in D5 problem?


Paste some mode VB and Delphi code...

Other Threads