Microsoft KB Archive/29547

{|
 * width="100%"|

DOCERR: Initiating DDE Conversation w/ Instance of Win Excel

 * }

Q29547

-

The information in this article applies to:


 * Microsoft Windows Software Development Kit (SDK) versions 3.0, 3.1

-

SUMMARY
The documentation for the EXEC macro on page 70 of the &quot;Microsoft Excel Function Reference&quot; manual for version 3.0 and on page 138 of the &quot;Microsoft Excel Function Reference&quot; manual for version 4.0 incorrectly refers to its return value as &quot;the Microsoft Windows task ID number of the started program.&quot; 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(&quot;USER&quot;,&quot;GetFocus&quot;,&quot;H&quot;)&quot;      | =CALL(A7)                              | <== hWnd -6                              | <==GWW_HINSTANCE =REGISTER(&quot;user&quot;,&quot;GetWindowWord&quot;,&quot;HHI&quot;)&quot;| <==GetInstance =CALL(GetInstance,hWnd,GWW_HINSTANCE)&quot; | <== hInstance =RETURN                              | Exec(&quot;YourApp.exe hInstance&quot;,1)&quot;       | - NOTE: For Microsoft Excel versions 2.x, the corresponding documentation for the EXEC macro is on page 275 of the &quot;Microsoft Excel Functions and Macros&quot; manual.

Additional query words: 3.00 3.10

Keywords : kb16bitonly

Issue type :

Technology : kbAudDeveloper kbWin3xSearch kbSDKSearch kbWinSDKSearch kbWinSDK300 kbWinSDK310