Excel and DDE

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
Dave1

Excel and DDE

Post by Dave1 » Tue Mar 16, 2004 12:31 am

I am hoping that there would be a way to get the content of the 'Name Box' in an Excel spreadsheet.
I know that this statement works (thanks to a script from Support):
DDERequest>Excel,c:\docs\book1.xls,R1C1,60
MessageModal>The content of R1C1 is: %result%

But I was hoping this statement:
DDERequest>Excel,c:\docs\book1.xls,"Name Box",result,60
MessageModal>The content of Name Box is: %result%

Or:
DDERequest>Excel,c:\docs\book1.xls,Name Box,result,60
MessageModal>The content of Name Box is: %result%

But they don't. MsSchd would just hang.
My intent was for operator to click on a cell, the subsequent statement would POKE a value in it.

I hope that I would receive help here.

Thanks.

Satch
Newbie
Posts: 11
Joined: Wed Mar 30, 2005 3:51 pm

Excel and DDE

Post by Satch » Tue Oct 04, 2005 4:37 pm

If you could set focus on the Name Box, you could set a Macro Scheduler variable to equal the contents of the Name Box somehow by using the clipboard.

Perhaps you or others will find a clue to setting focus on the Name Box in the following excerpt from the Web:


". . . following macro . . . set[s] the focus to the defined name box."


Public Declare Function SetFocus Lib "user32" (ByVal hwnd As Long) As Long

Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Public Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
(ByVal hWnd1 As Long, ByVal hWnd2 As Long, _
ByVal lpsz1 As String, ByVal lpsz2 As String) As Long

Sub SetFocusNameBox()
Dim Res As Long
Res = SetFocus( _
FindWindowEx( _
FindWindowEx( _
FindWindow("XLMAIN", Application.Caption) _
, 0, "EXCEL;", vbNullString) _
, 0, "combobox", vbNullString))
End Sub

Satch
Newbie
Posts: 11
Joined: Wed Mar 30, 2005 3:51 pm

Excel and DDE

Post by Satch » Tue Oct 04, 2005 5:06 pm

Actually, there's a much, much easier way. If your spreadsheet file's name is Book1:


GetControlText>Microsoft Excel - Book1,ComboBox,1,Result


The variable Result will be set to equal the contents of the Name Box.

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