LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default DDE Question

I'm new to VBA programming and I'm trying to interface with an optical system
design program called Zemax. I've written the following bit of code:

Sub Zemax_Test()
channelNumber = Application.DDEInitiate("Zemax", "temp")
x = Application.DDERequest(channelNumber, "GetFile")
y = 1
Worksheets("Sheet1").Range("B1").Value = CStr(x)
Worksheets("Sheet1").Range("B2").Value = y
Worksheets("Sheet1").Range("B3").Value = channelNumber
Worksheets("Sheet1").Range("B4").Value = IsError(channelNumber)
Worksheets("Sheet1").Range("B5").Value = IsError(x)
Application.DDETerminate channelNumber
End Sub

The resulting changes are made to column B of the spreadsheet:
Error 2042
1
2
FALSE
TRUE

The following is from the Zemax manual and describes their DDE interface:
*****
Establishing the link
To establish a DDE link with ZEMAX, the client program must broadcast a
message to all top level windows that includes a reference to the application
name, and the topic name. For ZEMAX, the application name is "ZEMAX", and the
topic name can be any non-NULL string. ZEMAX does not use the topic name,
just the application name and the "item". The item indicates to ZEMAX what
data is being requested. The various items ZEMAX supports are described
later. Once the DDE link is established, any analysis that can be done based
upon ray tracing may be performed by the server, and the data returned to the
client.
Terminating the link
When all computations are complete, and the DDE link is to be terminated by
the client, the client sends a termination message to the ZEMAX server. This
message will terminate only the server portion of ZEMAX, not ZEMAX itself.
Extracting data from ZEMAX
ZEMAX supports a number of capabilities under DDE. Each function is given a
name, called the "item", and this item is passed to the ZEMAX server using
the WM_DDE_REQUEST message. Any data ZEMAX requires (for example to trace a
ray) is passed to ZEMAX by encoding within the item name. Most items in ZEMAX
have names that require no further encoding, but some items have coded values
appended to the name. The values are appended to the item name and are
delimited by commas.
ZEMAX responds to each item request with a WM_DDE_DATA message, and the
message contains a pointer to a block of memory holding a string. Most data
is passed from ZEMAX back to the client application in a string, this
corresponds to F_TEXT format. The client application must extract the string
and free the memory for the string.
*****

I have no problem getting the DDE to work from Matlab. Also, typing
"=Zemax|temp!GetFile" into a cell behaves properly.

Does anybody have any suggestions?

Thanks,
Eric

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Newbie Question - Subtraction Formula Question [email protected] Excel Discussion (Misc queries) 3 May 5th 06 05:50 PM
Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good davegb Excel Programming 1 May 6th 05 06:35 PM
Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good you [email protected] Excel Programming 0 April 27th 05 07:46 PM
Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good you [email protected] Excel Programming 23 April 23rd 05 09:26 PM
Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good you [email protected] Excel Programming 0 April 22nd 05 03:30 PM


All times are GMT +1. The time now is 07:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"