Hi together,
in case you already programmed something with DDE, you might
be able to help me quite a lot.
Following problem:
I'd like to call a function written in Delphi from Access via DDE.
I already programmed something with DDE from Access to Winword
that works just fine (see the two functions at the end of the
article).
Now I'd like to call a function written in Delphi. My problem is,
how do I write a DDE-Server in Delphi?
The function should get three strings as parameter and return
a string as the result.
In case you've got an idea or even a little example program,
I'd be very happy to receive an answer as email.
Thank you very much.
Ciao Roland :)
P.S.: Example with Winword:
To call a command in Winword, just start:
Call DDE_RequestToWinword("[MsgBox ""This is a Winword-Msgbox.""]");
--- schnipp ---
' The following code works without any problem,
' it just an example that might help.
' Returns true, if a channel could be opened, false otherwise
Public Function DDE_MyInitiate(Location As String, Application As
String, Theme As String, ByRef Channel As Variant) As Boolean
Dim TaskID As Variant
On Error Resume Next
' Test, if the application is opened already
Channel = DDEInitiate(Application, Theme)
If (Err) Then
' Application is not opened yet
Err = 0
' Application has to be opened first
TaskID = Shell(Location, vbMinimizedNoFocus)
' Set Focus back to the formular that was opened last
' works automatically with vbMinimizedNoFocus
' AppActivate "Microsoft Access"
' Forms(FormNameStr).SetFocus
If (Err) Then
MsgBox "DDE_MyInitiate: " + Application + " could not be opened!"
Else
' Since the application is opened now, a session may be started
' If it will work, Err will be = 0 and DDE_MyInitiate returns true,
' false otherwise
Channel = DDEInitiate(Application, Theme)
End If
End If
DDE_MyInitiate = (Err = 0)
End Function
Public Sub DDE_RequestToWinword(Command As Variant)
Dim Channel As Variant
If (DDE_MyInitiate("c:\winword.exe", "Winword", "System", Channel)) Then
DDEExecute Channel, Command
DDETerminate Channel
End If
End Sub
--- schnapp ---