Jump to content

Ddeml Server for Excel - asking for help


ian.b
 Share

Recommended Posts

Hi :)

As a long time AutoIt end user for my own needs, i can script many routines, but unfortunately

i am not able to handle more advanced tasks - i mean DDE Server for Excel

I know that there is DDEML UDF created by doudou

http://www.autoitscript.com/forum/index.ph...hl=dde&st=0

There are a few forum topics dealing with DDE, especially MsCreatoR's handling urls,

but i still can not create the server.

I assume, that i do not have to worry about client side - Excel has the client/server build-in,

and the formula: =DdemlSrv|Topic!Ithem in a cell makes the DDE connection with the DdemlSrv Server.

To build the DdemlSrv to work with Excel (or any other client supporting DdemlSrv|Topic!Ithem format)

i have found an kb article from Microsoft right to the point, but it is written in Visual C++,

i am not able to implemment the code:

http://support.microsoft.com/kb/238133

For testing purpose, i have created a simple script, where the label caption is changed randomly

and it is supposed to be the Item for the DDE conversation with Excel - i have not put my "dde effort" in the code,

only a few lines from doudou server example.

CODE
#include <ButtonConstants.au3>

#include <GUIConstantsEx.au3>

#include <StaticConstants.au3>

#include <WindowsConstants.au3>

#include <DDEML.au3>

#include <DDEMLServer.au3>

#include <DDEMLClient.au3>

Opt("OnExitFunc", "CleanExit")

Global $hszSrvService = 0

If $DMLERR_NO_ERROR = _DdeInitialize("OnDDE_", $APPCLASS_STANDARD) Then

$hszSrvService = _DdeCreateStringHandle("DdemlSvr") ;

If Not _DdeNameService($hszSrvService, $DNS_REGISTER) Then MsgBox(0, "DdemlSvr", "Failed to register service")

Else

MsgBox(0, "DdemlSvr", "Failed to initialize service")

EndIf

#Region ### START Koda GUI section ### Form=

$Form1 = GUICreate("DdemlSvr", 212, 88, 193, 115)

$Label1 = GUICtrlCreateLabel("Number:", 32, 16, 44, 17)

$lblNumber = GUICtrlCreateLabel("0", 112, 16, 90, 17)

$btnStart = GUICtrlCreateButton("Start", 16, 48, 81, 25, 0)

$btnStop = GUICtrlCreateButton("Stop", 120, 48, 73, 25, 0)

GUICtrlSetTip (-1,"Sometimes it has to be pressed many times to work ?")

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case $btnStart

_fRandomNumber (500)

EndSwitch

WEnd

Func _fRandomNumber ($Delay)

Do

$No = Round (Random (-10,10),4)

GUICtrlSetData ($lblNumber,$No)

Sleep ($Delay)

$nMsg = GUIGetMsg()

Until $nMsg = $btnStop

MsgBox(0,0,0,1) ;Loop is broked

EndFunc

;DDE functions

Func CleanExit()

If 0 <> $hszSrvService Then

_DdeNameService($hszSrvService, $DNS_UNREGISTER)

_DdeFreeStringHandle($hszSrvService)

EndIf

_DdeUninitialize()

ConsoleWrite("CleanExit" & @CRLF)

EndFunc

Could someone help me to create this server?

TIA

ian

Link to comment
Share on other sites

  • 3 months later...

There are a few forum topics dealing with DDE, especially MsCreatoR's handling urls,

but i still can not create the server.

I assume, that i do not have to worry about client side - Excel has the client/server build-in,

and the formula: =DdemlSrv|Topic!Ithem in a cell makes the DDE connection with the DdemlSrv Server.

To build the DdemlSrv to work with Excel (or any other client supporting DdemlSrv|Topic!Ithem format)

i have found an kb article from Microsoft right to the point, but it is written in Visual C++,

i am not able to implemment the code:

http://support.microsoft.com/kb/238133

For testing purpose, i have created a simple script, where the label caption is changed randomly

and it is supposed to be the Item for the DDE conversation with Excel - i have not put my "dde effort" in the code,

only a few lines from doudou server example.

CODE
#include <ButtonConstants.au3>

#include <GUIConstantsEx.au3>

#include <StaticConstants.au3>

#include <WindowsConstants.au3>

#include <DDEML.au3>

#include <DDEMLServer.au3>

#include <DDEMLClient.au3>

Opt("OnExitFunc", "CleanExit")

Global $hszSrvService = 0

If $DMLERR_NO_ERROR = _DdeInitialize("OnDDE_", $APPCLASS_STANDARD) Then

$hszSrvService = _DdeCreateStringHandle("DdemlSvr") ;

If Not _DdeNameService($hszSrvService, $DNS_REGISTER) Then MsgBox(0, "DdemlSvr", "Failed to register service")

Else

MsgBox(0, "DdemlSvr", "Failed to initialize service")

EndIf

#Region ### START Koda GUI section ### Form=

$Form1 = GUICreate("DdemlSvr", 212, 88, 193, 115)

$Label1 = GUICtrlCreateLabel("Number:", 32, 16, 44, 17)

$lblNumber = GUICtrlCreateLabel("0", 112, 16, 90, 17)

$btnStart = GUICtrlCreateButton("Start", 16, 48, 81, 25, 0)

$btnStop = GUICtrlCreateButton("Stop", 120, 48, 73, 25, 0)

GUICtrlSetTip (-1,"Sometimes it has to be pressed many times to work ?")

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case $btnStart

_fRandomNumber (500)

EndSwitch

WEnd

Func _fRandomNumber ($Delay)

Do

$No = Round (Random (-10,10),4)

GUICtrlSetData ($lblNumber,$No)

Sleep ($Delay)

$nMsg = GUIGetMsg()

Until $nMsg = $btnStop

MsgBox(0,0,0,1) ;Loop is broked

EndFunc

;DDE functions

Func CleanExit()

If 0 <> $hszSrvService Then

_DdeNameService($hszSrvService, $DNS_UNREGISTER)

_DdeFreeStringHandle($hszSrvService)

EndIf

_DdeUninitialize()

ConsoleWrite("CleanExit" & @CRLF)

EndFunc

Could someone help me to create this server?

TIA

ian

Firstly, what is the purpose of Your server program? Since it lacks all DDE callbacks (OnDDE_ functions) it would simply ignore DDE communication targeted to it. In case You removed them deliberately to shorten the post - this was not a very good idea.

Secondly, I still not understand how that formula in an Excel cell can achieve a DDE transaction. It would perhaps establish a connection to a server by topic and item and if it did You would see console output in OnDDE_Connect which You don't have in Your code. However if You want to get usefull data from the client You will have to return 1 from OnDDE_Connect (what isn't there), commit a transaction from Excel (may be some other formula?) and then catch the data in another callback (OnDDE_Execute f.i.) that Your code again misses.

UDFS & Apps:

Spoiler

DDEML.au3 - DDE Client + Server
Localization.au3 - localize your scripts
TLI.au3 - type information on COM objects (TLBINF emulation)
TLBAutoEnum.au3 - auto-import of COM constants (enums)
AU3Automation - export AU3 scripts via COM interfaces
TypeLibInspector - OleView was yesterday

Coder's last words before final release: WE APOLOGIZE FOR INCONVENIENCEĀ 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...