DDERequest and Excel Tip
Moderators: Dorian (MJT support), JRL
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
DDERequest and Excel Tip
I have frequently tried DDE with Excel and failed to get data.
I had done Searches on the forum and tried to follow what others had done.
I often got the messages DDE_SERVICE_INVALID or DDE_TIMED_OUT.
Not having time to dig in deeper I quickly went away and found another solution.
But today I finally cracked the code.
So I thought I would include my discovery here to save time for others.
---------------
This is the basic syntax from the Help section:
DDERequest>Server,Topic,Item,Result,Timeout
---------------
This is the syntax I frequently found in the forum for Excel:
DDERequest>Excel,yourfile.xls,RowColumn,yourVariable,HowLongToWait
---------------
This is the syntax that I would suggest for Excel:
DDERequest>Excel,yourfile.xls,R(RowNumber)C(ColumnNumber),yourVariable,HowLongToWait
Ignore the ( ) symbols in line above, for reference only to show the letters R and C are needed with a number.
Example to get data from cell D21:
DDERequest>Excel,yourfile.xls,R21C4,yourVariable,HowLongToWait
---------------
Things leading to this syntax:
1. Normal references to cells in Excel are ColumnLetter-RowNumber, such as G5, D21, B3, etc.
2. Syntax needs the Row before the Column, opposite sequence of normal reference. Tendency was to put in G5, D21, B3 which was wrong and led to failures.
3. Syntax needs R/C before the RowNumber and the ColumnNumber. Tendency was to enter R5CG, R21CD, R3CB.
4. Syntax needed calls for the ColumnNUMBER, NOT the ColumnLETTER that is used in normal reference. That was the biggest discovery that solved this for me. I now need to convert G=7, D=4, B=2. So now I see these must be entered as G5=R5C7, D21=R21C4, B3=R3C2.
Success!
---------------
Once you see it explained it may seem quite obvious, but I have struggled with this too often, and hope this explanatioin will save work for someone else.
Also not mentioned was that spreadsheet must be opened first for DDE to work. This was probably obvious to those who have worked with DDE before, but this was new to me., So, for new DDE users, note that lines like these should preceed the DDERequest line.
Run Program>drive\path\excel.exe drive\path\yourfile.xls
WaitWindowOpen>Microsoft Excel*
I have not tried this with DDEPoke, but suspect the same rules will apply.
Perhaps the Help section could provide something like this example in the Help section.
And/Or this posting could also be placed in the forum for Scripts and Tips?
I had done Searches on the forum and tried to follow what others had done.
I often got the messages DDE_SERVICE_INVALID or DDE_TIMED_OUT.
Not having time to dig in deeper I quickly went away and found another solution.
But today I finally cracked the code.
So I thought I would include my discovery here to save time for others.
---------------
This is the basic syntax from the Help section:
DDERequest>Server,Topic,Item,Result,Timeout
---------------
This is the syntax I frequently found in the forum for Excel:
DDERequest>Excel,yourfile.xls,RowColumn,yourVariable,HowLongToWait
---------------
This is the syntax that I would suggest for Excel:
DDERequest>Excel,yourfile.xls,R(RowNumber)C(ColumnNumber),yourVariable,HowLongToWait
Ignore the ( ) symbols in line above, for reference only to show the letters R and C are needed with a number.
Example to get data from cell D21:
DDERequest>Excel,yourfile.xls,R21C4,yourVariable,HowLongToWait
---------------
Things leading to this syntax:
1. Normal references to cells in Excel are ColumnLetter-RowNumber, such as G5, D21, B3, etc.
2. Syntax needs the Row before the Column, opposite sequence of normal reference. Tendency was to put in G5, D21, B3 which was wrong and led to failures.
3. Syntax needs R/C before the RowNumber and the ColumnNumber. Tendency was to enter R5CG, R21CD, R3CB.
4. Syntax needed calls for the ColumnNUMBER, NOT the ColumnLETTER that is used in normal reference. That was the biggest discovery that solved this for me. I now need to convert G=7, D=4, B=2. So now I see these must be entered as G5=R5C7, D21=R21C4, B3=R3C2.
Success!
---------------
Once you see it explained it may seem quite obvious, but I have struggled with this too often, and hope this explanatioin will save work for someone else.
Also not mentioned was that spreadsheet must be opened first for DDE to work. This was probably obvious to those who have worked with DDE before, but this was new to me., So, for new DDE users, note that lines like these should preceed the DDERequest line.
Run Program>drive\path\excel.exe drive\path\yourfile.xls
WaitWindowOpen>Microsoft Excel*
I have not tried this with DDEPoke, but suspect the same rules will apply.
Perhaps the Help section could provide something like this example in the Help section.
And/Or this posting could also be placed in the forum for Scripts and Tips?
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
Thanks Marcus, but sometimes I need to force myself to do my own understanding.
Sometimes a challenge becomes personal vs. technical, and I refuse to be beaten.
Looking back I have to wonder why this one was so difficult for me.
Ignoring the syntax, and looking at the values, I still do not know how one determined that EXCEL should be used for the Server.
At times I used drive\path\excel.exe. Who knew the format was RowNumberColumnNumber for Item?
I checked Excel Help and it was no help. I have checked some sites on DDE, but found little to help.
If it wasn't for the forum messages I would probably have given up and asked for help.
It would be good to find a reference that filled in the blanks for various programs, listing the values for Server, Topic, Item.
I am sure that at some point I will want to add/copy a value from Access, and then I will need the values for Server, Topic, and Item again.
I suppose it will be something like this:
DDERequest>Access,myDatabase.mdb,qryResultRowColumn,myVariable,myTime ?
Who knows, how to find out?
Anyway, I now have one more tool that I can use with Excel. Onward and forward.
Thanks for the support.
Sometimes a challenge becomes personal vs. technical, and I refuse to be beaten.
Looking back I have to wonder why this one was so difficult for me.
Ignoring the syntax, and looking at the values, I still do not know how one determined that EXCEL should be used for the Server.
At times I used drive\path\excel.exe. Who knew the format was RowNumberColumnNumber for Item?
I checked Excel Help and it was no help. I have checked some sites on DDE, but found little to help.
If it wasn't for the forum messages I would probably have given up and asked for help.
It would be good to find a reference that filled in the blanks for various programs, listing the values for Server, Topic, Item.
I am sure that at some point I will want to add/copy a value from Access, and then I will need the values for Server, Topic, and Item again.
I suppose it will be something like this:
DDERequest>Access,myDatabase.mdb,qryResultRowColumn,myVariable,myTime ?
Who knows, how to find out?
Anyway, I now have one more tool that I can use with Excel. Onward and forward.
Thanks for the support.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
I did find this link:
http://www.angelfire.com/biz/rhaminisys/ddeinfo.html
that has more than I really want to know, but does give some insight into DDE past and future.
Too much tech stuff.
Instead of reading, I may wait for the movie to come out.
http://www.angelfire.com/biz/rhaminisys/ddeinfo.html
that has more than I really want to know, but does give some insight into DDE past and future.
Too much tech stuff.
Instead of reading, I may wait for the movie to come out.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
Bob, you have made me a happy man with jour DDERequest syntax struggling. Sometimes I have the impression that the software experts (like you) know everything, but this prove that there also have too learn the correct syntax, and this is not always so obvious.
You are a lucky man, in this specific case of the DDERequest syntax, that you are using an English version of Excel. The people using a different language version of Excel have also to change the letter R (from Row) and C (from column) into the syntax of the local language. For a Dutch version of Excel (my version) one has to use R (from Rij) and K (from Kolom). So Bob, your suggested syntax for a Dutch version of Excel become DDERequest>Excel,yourfile.xls,R(RowNumber)K(ColumnNumber),yourVariable,HowLongToWait
Support, can you report this in the help file? Otherwise, it can takes a long time before one finds the correct syntax for a different language version of Excel.
Greetings.
Luciano
You are a lucky man, in this specific case of the DDERequest syntax, that you are using an English version of Excel. The people using a different language version of Excel have also to change the letter R (from Row) and C (from column) into the syntax of the local language. For a Dutch version of Excel (my version) one has to use R (from Rij) and K (from Kolom). So Bob, your suggested syntax for a Dutch version of Excel become DDERequest>Excel,yourfile.xls,R(RowNumber)K(ColumnNumber),yourVariable,HowLongToWait
Support, can you report this in the help file? Otherwise, it can takes a long time before one finds the correct syntax for a different language version of Excel.
Greetings.
Luciano
But this is about Microsoft Excel. It is not specifically about DDERequest. So where would we put it in the help file? Should we write about every piece of software in the world that uses DDE?Luciano wrote:Support, can you report this in the help file? Otherwise, it can takes a long time before one finds the correct syntax for a different language version of Excel.
MJT Net Support
[email protected]
[email protected]
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
Great timing Luciano.
I just started doing some work, remotely, for someone in Holland. He had mentioned that I could use English and he would translate visible text, like labels, etc. for the end user.
I do not anticipate the need to use DDE for that project, but will use Macro Scheduler. But it is good to know about this Excel anamoly.
I will try to remember that I saw this hint somewhere. It may come in handy.
I just started doing some work, remotely, for someone in Holland. He had mentioned that I could use English and he would translate visible text, like labels, etc. for the end user.
I do not anticipate the need to use DDE for that project, but will use Macro Scheduler. But it is good to know about this Excel anamoly.
I will try to remember that I saw this hint somewhere. It may come in handy.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!