Pelles C forum
C language => Windows questions => Topic started by: czerny on March 24, 2013, 10:44:53 PM
-
Hallo,
I have tried a ddeml example from MS. But it didn't work. Excel starts, the connection to the dde-server is ok, but I can not get further.
Can anybody have a look?
czerny
-
I can make Excel (and WinWord) execute commands using DdeClientTransaction:
Let esi='[OPEN("test_dde.xls")]'
void Len(esi)
inc eax ; string len including zero delimiter
invoke DdeClientTransaction, esi, eax, ebx, 0, 0, XTYP_EXECUTE, 10000, 0
Apologies that it's assembler - I hope the idea is clear... and it works just fine.
-
The problem is with the file test.xls. Should be created before being used.
Something like this:
char szTopic[] = "Test.xls"; // provide an excel file with entrys in A1 and A2
.
.
FILE *xls_file = fopen(szTopic,"w");
fclose(xls_file);
HINSTANCE hRet = ShellExecute(0, "open", szTopic, 0, 0, SW_SHOWNORMAL);
.
.
Laur
-
The problem is with the file test.xls. Should be created before being used.
This is self-evident!
Can you read A1 and A2?
czerny
-
For me, the ShellExecute part works, i.e. a testfile gets opened, but the subsequent connect fails:
hszApp = DdeCreateStringHandle(idInst, szApp, 0);
hszTopic = DdeCreateStringHandle(idInst, szTopic, 0);
hConv = DdeConnect(idInst, hszApp, hszTopic, NULL);
DdeFreeStringHandle(idInst, hszApp);
DdeFreeStringHandle(idInst, hszTopic);
if (hConv == NULL)
{
printf("DDE Connection Failed.\n");
printf("Paras: idInst=%i\nhszApp=%p\nhszTopic=%p\n", idInst, hszApp, hszTopic);
Sleep(1500); DdeUninitialize(idInst);
return 0;
}
DDE Connection Failed.
Paras: idInst=16777344
hszApp=0000c000
hszTopic=0000c001
hszApp and hszTopic look like valid handles.
However, when I change the second line to ...
hszTopic = DdeCreateStringHandle(idInst, "System", 0);
... the connection stands.
-
The problem is with the file test.xls. Should be created before being used.
This is self-evident!
Can you read A1 and A2?
czerny
The problem is with the file test.xls. Should be created before being used.
This is self-evident!
Can you read A1 and A2?
czerny
No is not and yes I can, see attachment.
Mainly look at main().
Laur
-
Please tell us Excel version too.
That example works with Excel version 2003, but not with 2010 ?
http://support.microsoft.com/kb/279721
EDIT. Windows 7 x64, 32-bit MS Office Home and Student 2010
-
Hi timo
Indeed I use 2003 and I was not aware of the differences between versions.
I'm sorry I can not be more helpful.
Laur
-
It works with Excel 2010.
-
For me it doesn't work neither with 2000 nor 2003. I do not think that it is a version problem.
-
No is not and yes I can, see attachment.
Mainly look at main().
This example creates an empty new file 'test.xls', establishes the dde-connection and not more.
-
Hi Czerny,
Your original C source posted above works fine, provided the file test.xls is available in the specified location.
-
@czerny
It is a Office language problem.
"R1C1" is for english version.
-
@czerny
It is a Office language problem.
"R1C1" is for english version.
Puuh! Unbelievable!
Thank you timovjl!