News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Excel and XTYP_ADVSTART

Started by jj2007, March 31, 2013, 10:32:56 AM

Previous topic - Next topic

jj2007

I have been fighting the whole evening with an attempt to get a DDE hotlink to Excel. It's normally done by invoking DdeClientTransaction like this (ToutEnMasm):

      invoke DdeClientTransaction,NULL,NULL,tr.Hconv,tr.HRubrique,\
            CF_TEXT,XTYP_ADVSTART + XTYPF_NODATA,TIMEOUT_ASYNC,addr tr.pdwResult

My code looks like this, and it fails (and so do other combinations of flags tried):

      push eax   ; ddx.hTemp = "R1:C1"
      invoke DdeClientTransaction, 0, 0, ddx.hSheet, ddx.hTemp, CF_TEXT, XTYP_ADVSTART, TIMEOUT_ASYNC, esp
      pop edx

Everything else works fine, I can read and write data from and to Excel. Unfortunately the code of ToutEnMasm has been deleted in the course of the forum transition :(

On the other, the whole World Wide Web does not offer a single page saying "Hey, I managed to get a hot link to Excel working", so at this point I wonder if Excel offers this feature at all...

dedndave

on the old archive (#2)...
http://www.masmforum.com/archive2012/9454_DDE.zip

see if that's what you want
it looks right - most of the comments are in French   :P

jj2007

Quote from: dedndave on March 31, 2013, 11:28:20 AM
see if that's what you want
it looks right - most of the comments are in French   :P

Nice toy, although Yves is known for "fatal error A1000: cannot open file : \masm32\include\perso32.inc" messages ;-)

Will try today to put my stuff into a GUI. Somebody wrote that Win32 console cannot handle all DDE messages, although that is not documented anywhere. Which is the main problem: This stuff is old and badly documented. But for using Excel as a source of data it is still the best technique...

> Why don't use Office Document Model ? Excel fully supports COM and there are
> some examples in VB and VC in MSDN and also on MS site.

Roger Abbot:
Because DDE programming is very simple compared to COM programming. It
is possible to do the job with a few lines of code and no dependency on
external dlls or the registry. COM versioning with updated components
can be an absolute PITA, DDE does not suffer from that. The essence of
DDE is to connect to an already running program, whereas COM is most
convenient when the client is creating objects and in sole control of
them. Often, you cannot guarantee which instance of a running
application COM will connect you to. With DDE you connect to a specific
spreadsheet, whichever instance owns it.

dedndave

well, by looking at dates, it appears that ~4200 would be about right
i found one named 4194_dynamiq.zip, but i don't think that's the one you want

jj2007

Thanks, Dave.

9454 is actually the right one, but 1. it suffers from various idiosyncratic error messages (perso32 not found... and if you provide that file, new errors pop up), and 2. it doesn't solve the problem. Yves uses the plain DDE with WM_ messages, not DDEML, and he doesn't deal with hotlinks to Excel.

Besides, my own further testing shows that even from a GUI app Excel simply refuses to launch an advise loop (DMLERR_NOTPROCESSED - with wrong paras, DdeGetLastError returns DMLERR_INVALIDPARAMETER).

So unless a miraculous solution pops up, the interface will not have hotlinks. As already mentioned, the World Wide Web does not reveal any evidence that real hotlinks can be established with Excel. Probably M$ just "forgot" to document this "feature" 8)

Tedd

This page implies it's possible, though converting to usable code may be a different matter :badgrin:

http://v8doc.sas.com/sashtml/os2/z1ples.htm

It looks like you have to explicitly state that you want a hotlink for it to work.
Potato2


jj2007

Quote from: dedndave on April 01, 2013, 02:40:42 AM
perhaps they are blocked in Italia   :P

They are not blocked, but they all deal with Excel in the role as hotlink client, not server...

Quote from: Tedd on March 31, 2013, 11:21:38 PMIt looks like you have to explicitly state that you want a hotlink for it to work.

Yes, that's what XTYP_ADVSTART is supposed to do: Ask the server to send a message if cells are changing. But the server (Excel) responds "Sorry, I won't process your demand". If you post bad paras, it responds with a different message. Meaning that he understands the request but refuses to process it.

Re SAS, I saw them, too, and wonder how they do it.

There is a workaround - polling - but it doesn't sound the right solution for a bigger spreadsheet.
Another workaround would be polling only for the size of a given range, certainly faster but you would miss changes that do not alter the size.

dedndave

i don't know much about using DDE (specifically, DDEML), but i am willing to have a go at it - lol

in reading, i see things like DdeInitialize and DdeCallback mentioned, but i do not see them mentioned in your posts
am i to assume you have all that going ?

dedndave

doing some reading.....

if you want to find old information, you have to go old - lol
looking around for things that were in vogue for windows 3.1, 95, 98
and older versions of office - i still use office 97 pro (under xp) - so i have some info on that
i have the Excel 97 SDK, which doesn't provide much help on DDE,
but it does offer some examples on creating XLL files, which you could possibly make use of
http://download.microsoft.com/download/excel97win/Install/1.0/W9XNT4XP/EN-US/excel97sdk.exe
http://download.microsoft.com/download/platformsdk/sample27/1/NT4/EN-US/Frmwrk32.exe
(i used 7-zip to extract files on both)

i suspect you could find more DDE info for "excel for windows 3.1" - perhaps the SDK

i also found these articles that may be helpful
http://msdn.microsoft.com/en-us/library/ms997518.aspx
http://msdn.microsoft.com/en-us/library/ms997524.aspx

on the 5th and 6th lines down, you will see a couple "Click here" downloads
the first one is for a server app - not what you want
but, the second one is for a client app, named DdeRecon.exe
it must be a self-extracting zip - i used 7-zip to extract files, as i always do

something that may provide further help is to google around for "DdeRecon"
you will see where other developers have used that demo as an example
i.e., they were following the same path as you

TouEnMasm


This one don't use perso32.inc (I have just replace copier by lstrcpy)
Hope he can be compiled without problem/
Fa is a musical note to play with CL

jj2007

Merci, Yves - ça marche avec des petites corrections:
- rename serveur.rc as asmserveur.rc
- rename client.rc as asmclient.rc
- change in asmclient.rc: #include <C:\MASM32\INCLUDE\RESOURCE.H>

However, it does not really solve my problem with the XTYP_ADVSTART call to Excel...

@Dave: have checked DdeRecon - see attachment. The original exe fails miserably with Excel 2003 on XP.

dedndave

it seems to work with Excel 97...



i am guessing the "|" chars are nulls

jj2007

Dave,

Where did you find that historic version of Excel? :dazzled:

In the meantime I posted A Number Cruncher's Easter Egg, to show off a little bit :biggrin:

Happy Easter to you, ToutEnMasm and Tedd (for good advice), and everybody else here  :t

dedndave

Quote from: jj2007 on April 01, 2013, 10:58:51 AM
Where did you find that historic version of Excel? :dazzled:

lol - back, about 1999, i needed Excel to be compatible with a business client
so - i got office 97 pro - not cheap, either
i really grew fond of PhotoEditor that came with it for a few functions (adjusting color, cropping)
in newer versions of office, they stopped including it
anyways, until i have to upgrade, i will use this one   :P
with the file converters and other updates, i can open most Excel documents
and, i sometimes use Word for writing

the point is - DdeRecon does work - you have to use the right syntax for "item"   :P

Quote from: jj2007 on April 01, 2013, 10:58:51 AM
Happy Easter to you, ToutEnMasm and Tedd (for good advice), and everybody else here  :t

Happy Easter, Jochen - and to all