The Fetch command retrieves data from Microsoft Query and sends it directly to the destination program.
The Fetch.Advise command updates the destination program automatically as values in Microsoft Query change, not just when the Fetch.Advise command is sent.
These commands are available on both the system channel and the query channel.
Syntax 1
Fetch.Advise(appname, topic, range, values)
Syntax 2
Fetch(appname, topic, range, values)
appname The name of the destination program to which the data is to be sent. Here are the appname arguments you'd use for Office programs:
Program | Value of appname |
---|---|
Microsoft Access | MSAccess |
Microsoft Excel | Excel |
Microsoft Word | WinWord |
topic The name of the worksheet, document, or control to which the data is to be sent.
range The area of the worksheet, document, or control to which the data is to be sent.
values The values to be retrieved from Microsoft Query. (For valid values, see the table below.)
Note The Fetch.Advise command automatically updates only query data, not request items or row#col# references.
Can be one of the following values:
Value | Description |
---|---|
Request_item | The information to return; for example, QueryDefinition. |
row#col# | A reference to retrieve specific rows and columns, such as R3C5 from Microsoft Excel. |
/Headers | Retrieves column names. |
/Rownum | Retrieves row numbers. |
All | Retrieves all records. |
For Fetch.Advise, the channel created to return data to the destination program isn't closed until a Fetch.Unadvise or Close command is sent.
Example
This example uses the NumRows and NumCols request items to return the number of rows and columns in the query, and then returns the values with column headings to a Microsoft Excel worksheet named "Sheet1."
rows=REQUEST(Chan,"NumRows")
cols=REQUEST(Chan,"NumCols")
DDEExecute chan, "[Fetch(""Excel"", ""Data.xls!Sheet1"", _
""R1C1:R"&rows&"C"&cols&""", ""All/Headers"")]"