DDERequest: Default Excel worksheet when none specified

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
evangelmike
Pro Scripter
Posts: 56
Joined: Sun May 11, 2008 9:39 pm

DDERequest: Default Excel worksheet when none specified

Post by evangelmike » Wed Jul 09, 2008 4:11 am

Greetings! One of the blogs has the following:
"Use the DDERequest command to retrieve an item of data from Excel. Excel must be running and the spreadsheet must already be open. We could easily make our macro open the worksheet for us using the ExecuteFile command (or Run Program). We then use DDERequest something like this:

DDERequest>Excel,c:\\\documents\\\example.xls,R1C1,myVariable,60

The first parameter is the Server name, which is always just Excel for Microsoft Excel. The second parameter, the DDE “Topicâ€
May you have a blessed day!

Michael D Fitzpatrick
Reg. US Patent Agent

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Jul 09, 2008 5:59 am

I believe it will always be the first sheet in the workbook if a sheet is not specified.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

evangelmike
Pro Scripter
Posts: 56
Joined: Sun May 11, 2008 9:39 pm

Post by evangelmike » Wed Jul 09, 2008 3:40 pm

Greetings! I ran a DDEPoke test on my file BookIssuersChgd.xlsm. The first worksheet of BookIssuersChgd.xlsm has no data, and the next 22 worksheets have data. I ran the following macro both with the focus set to BookIssuersChgd.xlsm, and with the focus set to another workbook:

[code]
SetFocus>BookIssuersChgd.xlsm
DDEPoke>Excel,C:\Documents and Settings\Michael Fitzpatrick\InsiderIndustryResults\BookIssuersChgd.xlsm,R1C10,HELLO!!!

SetFocus>BookDates.xlsm
DDEPoke>Excel,C:\Documents and Settings\Michael Fitzpatrick\InsiderIndustryResults\BookIssuersChgd.xlsm,R1C10,HELLO!!!
[/code]

In both cases, row 1 column 10 of the last worksheet added to workbook BookIssuersChgd.xlsm was set to HELLO!!!. I also ran this test numerous times with the focus manually set to the first worksheet and various later added worksheets of BookIssuersChgd.xlsm always with the result that row 1 column 10 of the last worksheet added to workbook BookIssuersChgd.xlsm was set to HELLO!!!. Of course it is possible that under other scenarios a different worksheet will be "Poked".
May you have a blessed day!

Michael D Fitzpatrick
Reg. US Patent Agent

evangelmike
Pro Scripter
Posts: 56
Joined: Sun May 11, 2008 9:39 pm

Post by evangelmike » Wed Jul 09, 2008 7:46 pm

Greetings! Further testing reveals that one may add a new worksheet anywhere within a collection of worksheets--i.e. at the beginning of a collection of worksheets, anywhere in the middle, or at the end of a collection of worksheets. (One adds a new worksheet by rightclicking on any of the worksheet tabs at the bottom of the Excel window and selecting Insert from the menu, or, in VBA, with the Sheets.Add instruction.) When DDEPoke is used to set a value in a workbook and the worksheet is not specified, DDEPoke stores its value in the last worksheet of the collection, not the last worksheet added. May you all have blessed days.
May you have a blessed day!

Michael D Fitzpatrick
Reg. US Patent Agent

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts