Document Type: Technical Note
Microsoft Excel DDE Commands
Keywords: VEE, Excel, DDE
Situation:
This document discusses commands that can be used to communicate
between HP VEE and Microsoft Excel using Dynamic Data Exchange (DDE).
The commands have been tested using Excel 95 and 97 in Windows
95 and NT.
The drawback to using DDE is that the commands that an application
uses may or may not be documented. The commands are dependent on
the application that is being talked to and if they are not documented,
VEE has no way of communicating with the application. For this reason,
if VEE 5.0 is being used it is best to use Active-X Automation to
transfer data to other applications. Active-X is typically better
documented (ie, documentation exists) and is more current.
Solution:
The following are items that can be read or written to using the
READ or WRITE transaction in the TO/FROM DDE object in VEE.
Item |
Comment |
SYSITEMS |
Returns a list of items available to be read. |
STATUS |
Returns the status of Excel. |
TOPICS |
Returns a list of topics available for use. |
FORMATS |
List of formats (unknown what they do). |
SELECTION |
Currently selected range of cells. |
PROTOCOLS |
List of current protocols (unknown). |
EDITENVITEMS |
(unknown). |
The above items would all be read from Excel using the SYSTEM topic. The
only useful item would be TOPICS. TOPICS returns a list of all topics
that can be used. This would be useful using the control input pin called
topic on the To/From DDE object. Due to lack of documentation, the return
values of other items usefulness is unknown.
The following are commands that are sent to Excel using the EXECUTE
transaction in VEE.
Command |
Result |
[APP.RESTORE] |
Restore Excel from minimized (or maximized) state to normal view. |
[APP.MAXIMIZE] |
Maximize Excel. |
[APP.MINIMIZE] |
Minimize Excel. |
[OPEN("filename")] |
Open the Excel file called filename. |
[SAVE.AS("filename")] |
Save the Excel file into new file called filename. |
[SELECT("cellrange")] |
Selects the cells specified by cellrange. |
An example of syntax in VEE for the open statement would be as follows:
EXECUTE CMND "[OPEN(\"C:\\MY DOCUMENTS\\MYDATA.XLS\")]"
Note the extra backslash before the quote around the filename and directory
slashes, this tells VEE that the character following is a special character
and to embed that character into the string.
The cellrange would have the following formats: RxCy Rx Cy RxCy:RnCm
RxCy would select a single cell at row number X and column number Y
Rx would select the entire row X
Cy would select entire column Y
RxCy:RnCm would select the range starting a row X column Y and ending
at row M column N
This would be the same syntax used to read or write data to the Excel
spreadsheet. The cellrange would be inserted a the ITEM specifier.
After Excel is maximized or restored, the following commands can be
executed.
%FXN Exit Excel and discard changes.
%FXY Exit Excel and save changes (this works automatically if an existing file was
opened)
%FP~ Print the current spreadsheet to the default printer.
The definition of the above sequences are:
% emulates pressing the ALT key
F selects the File menu
X selects the eXit option
P selects the Print option
Y presses the Yes button on save dialog box
N presses the No button on save dialog box
~ emulates pressing the Enter key
Revision 1.0 |
15 Dec 98 |
lec |
Copyright Hewlett-Packard Company 1998
This information is subject to change without notice and is provided "as is"
with no warranty.
Hewlett-Packard shall not be liable for any direct, indirect, special, incidental or
consequential damages in connection with the use of this material.
|