Tim: Thanks for the reply. It's made me go back to look for some way to send Excel what it wants, which led to some other ideas.
First: I found on google a MS Word document from NI about the DDE formats Excel supports - in particular, the "xlTable" format: http://forums.ni.com/ni/attachments/ni/170/113711/1/dde.doc (see also this C++ code: http://support.microsoft.com/kb/238133) I also stumbled across a mention somewhere in Google that Excel will request data using the clipboard format in the order listed in the above NI doc, and if you're not returning data with that format, your application should spit back a "false", or "not supported", or something to that effect, at which point Excel will make another request using the next format on the list, and so on and so forth until you get to something you both agree on or until you run out of formats. I purposely did something bad in my server response which generated an exception (ie, return hex('164116259')) - when I call this from Excel, I get 9 exception reports on the console. If I call it from Word, I only get 1 exception report. Perhaps that's a sign that Excel is making multiple requests with different format types, until it hits the CF_TEXT we actually send back? Reading through the code in stddde.cpp, it seems like it might not be handling checks for that correctly. In CDDEServer::DoCallback, it gets a wFmt passed in, which then gets passed along to CDDEServer::Request. CDDEServer::Request passes the wFmt to the request method of whatever CDDETopic matches. In CDDETopic, if m_strName is blank, it gets passed to NSRequest(pszItem, ppData, pdwSize) <- which doesn't list anything at all about the wFmt command. That looks like it gets passed into Python, which ultimately gets passed back up to CDDEServer::DoCallback, which returns data using the wFmt that was passed in. But if Excel was expecting this xlTable format, maybe that's why this error 2042 shows up? It looks like if you name the string topic, then it will get passed to CDDEStringTopic, which ASSERTS wFmt is CF_TEXT. I tried to pass back a string like "16411625", hoping I'd get "5" returned, but it didn't work. Anyway, do you think adding in a check to the NSRequest function that wFmt is really CF_TEXT might fix this issue? Thanks for whatever help you can provide. On Fri, Dec 26, 2008 at 10:49 AM, <t...@probo.com> wrote: > On Wed, Dec 24, 2008 at 05:28:18PM -0800, David Haas wrote: >> >> I've run into a problem with DDE which, after much googling and trial >> & error, I managed to work around, but I'm pretty sure there's a >> better solution. >> >> I think the problem is this: there's currently no way for a python DDE >> server to pass an array back as a response from a DDE Request - it's >> either a string, or nothing. Since Excel expects the response it >> receives from a DDE Request that it makes to be an array, it dies >> (with what I believe is an Error 2042) when communicating with a >> Python DDE server. > > DDE works exclusively in strings. So, the key is to figure out how > to encode the array as a string in order to satisfy Excel. I've been > searching for an Excel DDE reference guide without success, although > I'm certain there must be one. > -- > Tim Roberts, t...@probo.com > Providenza & Boeklheide, Inc. > _______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32