DDE commands to Excel Server

zorfor

New Member
Joined
Jul 23, 2008
Messages
4
XPHomeSP3, Excel 97, VS2005,C++

Hi, I have a need to communicate from my c++ dll to Excel.
I can Poke & Request data ok however when I try to run a macro it does not run..

Using Application "Excel", topic "System" or topic "C:\test.xls" and DdeClientTransaction with XTYP_EXECUTE i can submit a DDE command that has no parameters such as [QUIT] but any commands (including RUN) that have paramters in brackets does not run.. eg RUN("MyMacro").

By removing the square brackets i can see the command gets written to the active cell as RUN"MyMacro" ie. the round brackets have been stripped.

Debugging the text from the c++ code i can see the brackets are delivered to the DdeClientTransaction... but seem to be stripped somewhere.

All the references/examples make no mention of not having the brackets or issues in transporting them..
I have tried both unicode and ascii versions of the DDE calls in c++...

Does anyone have some clues or working examples (from c++).

Thanks if you can share some info.. (thanks for reading too ;)

Cheers
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
StrItem = "[RUN(""MyMacro"")]"

Are you using this syntax? Note double quotes...
 
Upvote 0
Hi, thanks for quick reply :)

I had tried that.. and retried it just now.. these are the results i get from various trials...

Sent Received
<TABLE dir=ltr border=0 cellSpacing=0 cellPadding=2 width=279><TBODY><TR><TD height=16 width="43%">
RUN("msg")​
</TD><TD height=16 width="14%">
</TD><TD height=16 width="43%">
RUN"msg"​
</TD></TR><TR><TD height=16 width="43%">
RUN(("msg"))​
</TD><TD height=16 width="14%">
</TD><TD height=16 width="43%">
RUN"msg"​
</TD></TR><TR><TD height=16 width="43%">
R U N ( " m s g " )​
</TD><TD height=16 width="14%">
</TD><TD height=16 width="43%">
R U N " msg "​
</TD></TR><TR><TD height=16 width="43%">
RUN(""msg"")​
</TD><TD height=16 width="14%">
</TD><TD height=16 width="43%">
RUN""msg""​
</TD></TR><TR><TD height=16 width="43%">
RUN\("msg"\)​
</TD><TD height=16 width="14%">
</TD><TD height=16 width="43%">
RUN\"msg"\​
</TD></TR><TR><TD height=16 width="43%">
RUN/('msg'/)​
</TD><TD height=16 width="14%">
</TD><TD height=16 width="43%">
RUN/"msg"/​
</TD></TR></TBODY></TABLE>

When enclosing with square brackets the commands dont work..
[QUIT] and [QUIT()] both work as () is not needed

Cheers
 
Upvote 0
I don't know C but have used both options in VB. Which one are you using?

<A HREF="http://msdn.microsoft.com/en-us/library/ms648711(VS.85).aspx" TARGET="_blank">Dynamic Data Exchange</A>

<A HREF="http://msdn.microsoft.com/en-us/library/ms648712(VS.85).aspx" TARGET="_blank">Dynamic Data Exchange Management Library</A>

Why are choosing DDE for these activities? Am curious because there are better ways of running macros such as COM/OLE or Excel's API.
 
Upvote 0
Hi, thanks Tom...

I am using DDEML. I've read through the docs again in the links you sent.. seems i am within spec.
I started debugging the c++ side assembly code from the ddeclienttransaction call to see if i could see the final send string... but without source :eek::confused::eek:

Next will be to load up a dde server shell to use to verify the correct text is arriving at the server.

I'm leaning towards some issue in the send text since all doco, samples and examples all agree on your syntax without mention of issues.

Why DDE? The main excel funtionality i needed to provide was to read and write a cell (which is working).. and even that is side functionality to other non excel requirements... it just seemed ole/automation was more than required. Adding the ability to run macros is a 'desireable' feature that may have to wait for next release. (perhaps i should read up on ole?)
My DLL provides extended function as a third party to a trading platform.

Thanks again... i'll when i've done some more testing.
 
Upvote 0
Sorry I could not help. My knowledge of C is limited to what I have been forced to learn in dealing with the API. I doubt that it will matter, but if you'd like you can send me a snippet of your relevant code. If you are like every other programmer out there who is human at the same time, you may just be missing something obvious. Probably not, but it would not hurt. *smiles* Have you posted in a C forum by any chance?

Post your code here if you can. If not, send it too me if you wish. Switch com and my username. com@gmail.tstom1970
 
Upvote 0
:(

What happend to my post? I just happend to be passing and notice my reply is not here.... did I not click submit?

the day after your posting Tom I found the problem by loading a different C->Excel DDE ..... the first example prog i had used had coded a parameter to "0", which turned out to be a specifier for the character code set... seems the old examples worked ok with zero in an ascii environment.. but in unicode capable environment the param needs to be set to ascii or uncode flag values.

Thanks for your help,
Cheers.
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,816
Members
449,049
Latest member
cybersurfer5000

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top