DOCERR: Initiating DDE Conversation w/ Instance of Win Excel

Last reviewed: July 22, 1997
Article ID: Q29547
3.00 3.10 WINDOWS kbprg kbdocerr

The information in this article applies to:

  • Microsoft Windows Software Development Kit (SDK) for Windows versions 3.0 and 3.1

SUMMARY

The documentation for the EXEC() macro on page 70 of the "Microsoft Excel Function Reference" manual for version 3.0 and on page 138 of the "Microsoft Excel Function Reference" manual for version 4.0 incorrectly refers to its return value as "the Microsoft Windows task ID number of the started program." However, it is not the value returned by the Windows KERNEL routine GetCurrentTask(). EXEC() returns the instance handle to the EXEC()'d application.

MORE INFORMATION

Windows and Excel do not provide an easy way to find out which instance of Excel called the application. However, the correct value can be obtained.

The following is a sample macro that uses the REGISTER and CALL functions to obtain the instance handle to the version of Excel that is running. That information then can be passed to the application inside the EXEC call. However, the value in hInstance must be appended as a string for the EXEC call.

The following is the text version of the macro sheet:

             A                          |        B
This is an example of how to obtain the | instance and then pass that value to the|
EXEC'd application:                     |
                                        |
=STEP()                                 |
Get instance handle of current window. |
=REGISTER("USER","GetFocus","H")"       |
=CALL(A7)                               | <== hWnd
       -6                               | <==GWW_HINSTANCE
=REGISTER("user","GetWindowWord","HHI")"| <==GetInstance =CALL(GetInstance,hWnd,GWW_HINSTANCE)" | <== hInstance
=RETURN()                               |
Exec("YourApp.exe  hInstance",1)"       |

NOTE: For Microsoft Excel versions 2.x, the corresponding documentation for the EXEC() macro is on page 275 of the "Microsoft Excel Functions and Macros" manual.


Additional reference words: 3.00 3.10
KBCategory: kbprg kbdocerr
KBSubcategory: UsrDde
Keywords : kb16bitonly


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 22, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.