# Excel: Using COMMAND() to Send an Excecute String to Q+E

Last reviewed: September 12, 1996
Article ID: Q100655
The information in this article applies to:

- Microsoft Excel for Windows, versions 2.1, 2.1c, 2.1d, 3.0, 4.0
- Q+E versions 2.5, 3.0, and 3.0a

## SUMMARY

If you are using Microsoft Excel version 2.x, 3.0 or 4.0 and Q+E version 2.5, 3.0, or 3.0a, you can use the Microsoft Excel COMMAND() function to construct large execute commands and send them to Q+E a portion at a time. This function exists because some macro languages, such as the Microsoft Excel macro language, have limits on the size of character variables.

## MORE INFORMATION

The COMMAND() function requires two arguments. The first argument, op_num, is a number from 1 to 3 that specifies how Q+E receives and handles the second argument, exec_string.

Note the following:

- If op_num is 1: Q+E initializes a buffer and saves exec_string
- If op_num is 2: Q+E adds the exec_string to the buffer
- If op_num is 3: Q+E adds the exec_string and executes the buffer

exec_string is the string of commands executable by Q+E. The syntax for these commands is the same format that is used with the DDE EXECUTE function. Each command must be enclosed in square brackets and the entire string, including the square brackets, must be enclosed in quotation marks.

The following example assumes that Q+E is listed correctly in the PATH statement and that the file ADDR.DBF is in the subdirectory C:\QE:

       A1:  chan=INITIATE("qe","system")
       A2:  =EXECUTE(chan,"[command(1,'[open(''select * from ')]")
       A3:  =EXECUTE(chan,"[command(2,'dbasefile|')]")
       A4:  =EXECUTE(chan,"[command(3,'c:\qe\addr.dbf'')]')]")
       A5:  =RETURN()

- The first line initializes the DDE channel.
- The second line causes Q+E to initialize a buffer and save the string "'[open(''select * from ", without the double quotation marks. Note, there is a space between the word "from" and the single quotation mark. Also, the asterisk signifies bringing in all fields.
- The third line sends the string "dbasefile|" (without the quotation marks), which Q+E concatenates to the buffer.
- The fourth line sends the string "c:\qe\addr.dbf'')]'", (without the double quotation marks), which Q+E concatenates to the buffer before executing the complete command buffer.

  The example above is equivalent to the following macro:

         A1:  chan=INITIATE("qe","system")
         A2:  =EXECUTE(chan,"[open(''select * from dbasefile|c:\qe\addr.dbf'')]")
         A3:  =RETURN()

> KBCategory: kbother
> KBSubcategory:

> Additional reference words: 2.10 2.10c 2.10d 3.00

> 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: September 12, 1996
©1997 Microsoft Corporation. All rights reserved. Legal Notices.