Microsoft KB Archive/70712

{| = Using Tabs and Paste.Append from an Excel Macro to Q+E =
 * width="100%"|

Last reviewed: November 2, 1994

Article ID: Q70712

SUMMARY
You can use the Paste.Append function of Q+E inside an Excel Execute function to append data to your database in Q+E. You can do this without copying anything to the Clipboard by using a string of field values separated by tabs.

MORE INFORMATION
The Paste.Append function of Q+E has one optional argument, &quot;field_values&quot;. If &quot;field_values&quot; is omitted, the new values are pasted from the Clipboard. &quot;field_values&quot; is a single argument with tabs separating field values. To use the argument &quot;field_values&quot;, you must use the Excel Char(9) function to concatenate tab characters. The number nine is the ASCII code for the tab character.

The example below does the following:


 * 1) Opens a DDE channel from Excel to Q+E.
 * 2) Opens a query window in Q+E for the file EMP.DBF.
 * 3) Turns on Allow Editing.
 * 4) Appends the data in cell A7, A8, and A9 on the Excel macro sheet into adjacent fields at the bottom of EMP.DBF.
 * 5) Terminates the channel.

NOTE: The example assumes that EMP.DBF is in a directory C:\EXCEL\QE. Modify the path to match your configuration.

Example
A1: chan=INITIATE(&quot;QE&quot;,&quot;System&quot;) A2: =EXECUTE(chan,&quot;[open('emp.dbf','dBasefile')]&quot;) A3: =EXECUTE(chan,&quot;[Allow.Edit(true)]&quot;) A4: =EXECUTE(chan,&quot;[Paste.Append('&quot;&A7&CHAR(9)&A8&CHAR(9)&A9&&quot;')]&quot;) A5: =TERMINATE(chan) A6: =RETURN A7: John A8: Smith A9: 12345

Additional Example
There is an example on page 105 of the &quot;Q+E for Microsoft Excel User's Guide&quot; that describes using Paste.Append from an Excel macro, but it does not describe how to concatenate cell contents into the &quot;field_values&quot; argument.