|
|
Document Type: ProgrammingHP VEE and Microsoft Excel DDE ExampleKeywords: VEE, Excel, DDE Purpose:This document covers DDE communication between HP VEE and Microsoft Excel running on a Language:HP VEE Operating System:Windows 95/NT Required Products:Microsoft Excel 95 or 97 Results:When the VEE program is executed, Excel should start minimized on Program:
|--------------------- To/From DDE --------------------------|
|------------------------------------------------------------|
| Application: Excel |
| Topic: System |
| Timeout: 5 |
|------------------------------------------------------------|
| Execute Cmnd: "[OPEN(\"C:\\MY DOCUMENTS\\MYDATA.XLS\")]" |
|------------------------------------------------------------|
|
|
|
|--------------------- To/From DDE --------------------------|
|------------------------------------------------------------|
| Application: Excel |
| Topic: MYDATA |
| Timeout: 5 |
|------------------------------------------------------------|
| Write Item: "R1C1" Text X Str |
|------------------------------------------------------------|
|
|
|
|--------------------- To/From DDE --------------------------|
|------------------------------------------------------------|
| Application: Excel |
| Topic: System |
| Timeout: 5 |
|------------------------------------------------------------|
| Execute Cmnd: "[APP.RESTORE]" |
| Execute Cmnd: "%FXY" |
|------------------------------------------------------------|
The first "To/From DDE" object launches and initiates communication
to Excel. It then executes the command to open the specified file. The
filename is embedded with quotes. The Excel syntax would be
[OPEN("C:\MY DOCUMENTS\MYDATA.XLS")]
but VEE requires the backslashes be entered to have the quotes and directory
slashes to be sent.
The second object writes data to the file. Application note 2120-1 and
2120-2 go into further detail on writing data to Excel. This example
writes a single value into the cell at row 1 column 1.
The third object closes the file. Although there are other ways using macros
to save the program, this is a fairly straight forward approach. The object
emulates keystrokes to activate menu items to exit the program. Before this
keystroke emulation can begin, the application must be restored to a visible
state (ie, non-minimized). The %FXY is sent to Excel. This emulates selecting
the file menu, then eXit, then pressing the Yes button to save the file. The
exact interpretation of the string is ALT(%)-File(F)-Exit(X)-Yes(Y).
If the programmer wanted to save the progam into a different filename, then the
third object would become:
|--------------------- To/From DDE -----------------------------|
|---------------------------------------------------------------|
| Application: Excel |
| Topic: System |
| Timeout: 5 |
|---------------------------------------------------------------|
| Execute Cmnd: "[APP.RESTORE]" |
| Execute Cmnd: "[SAVE.AS(\"C:\\MY DOCUMENTS\\NEWDATA.XLS\")]" |
| Execute Cmnd: "%FX" |
|---------------------------------------------------------------|
Download this example program VEE_EX.VEE
Copyright Hewlett-Packard Company 1998 |