Dynamic copy/paste using DDE with Python on Windows

Eric Brunel eric.brunel at pragmadev.com
Thu Oct 17 11:41:51 EDT 2002


Eric Brunel wrote:
> Thanks for the explanation, but there's apparently a little
> misunderstanding: what I want to do is use the regular "Paste special..."
> / "Paste link" feature in Word. In fact, the application is not only for
> me: other people will have to use it and creating a macro acting as the
> DDE client in each copy of Word for each person using this feature is
> really impossible.
> 
> Concerning your other post (DDE: supported or not? broken or not?), again
> thanks, but what I'm interested in is just whether the mechanism used to
> paste DDE links in Word is still used or not. Apparently, it's not: I
> tried to copy a refrence to a DDE topic/item in the clipboard the way it's
> described in the MSDN docs (custom clipboard format "Link", reference
> formatted like "application\0topic\0item\0\0"), but Word refused to paste
> anything from it. The DDE server seemed to work since inserting the DDE
> reference in Excel ("application|topic!item") works. But the "paste link"
> thing does not.

My mistake: it does. I just forgot to include something else than the DDE 
link in the clipboard, so Word refused to open its "Paste special" box. So 
I've got it working for text: I can copy text as a DDE link in Python and 
paste the link in Word. I'll post the code to the Python Wiki when I've 
cleaned it up (and when I've figured out what is the best place to post it 
in...)

Now, I want to do the same thing, but with a bitmap. A simple BMP would be 
OK. I've tried it, but I just can't figure out what I must return for the 
bitmap data (return value of the "Request" method in the object for the DDE 
topic, as in the DDE example in win32/demos/dde/ddeserver.py):
. I've tried to return the handle to the bitmap like when putting the data 
in the clipboard (result of the GetHandle method on the PyBitmap object), 
but Word refuses to paste the link
. I've tried to return the "bitmap bits" as returned by the GetBitmapBits 
method of the PyBitmap object: same result
. I've tried to return the contents of the bitmap file as a binary string: 
it made Python crash

Did anybody succeed in returning a BMP from DDE? If you did, how did you do 
it? TIA
-- 
- Eric Brunel <eric.brunel at pragmadev.com> -
PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com



More information about the Python-list mailing list