> ## Documentation Index
> Fetch the complete documentation index at: https://support.taltech.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Reading serial data into Word using DDE

> Read device data into a Word document in Word 95 or later with WinWedge using its more advanced DDE mode.

Instructions for Microsoft Word 95 and later

## Configuring WinWedge and Word

#### WinWedge DDE server settings

Remember to set WinWedge up in DDE Server Mode! See the [DDE Server Mode Setup Guide](https://support.taltech.com/winwedge/dde-server-mode-setup-guide.md).

DDE Application Name: **WinWord**

DDE Topic: **System**

DDE Command: **\[GrabData]**

## Creating the Word macro

#### Word instructions

When you create a VBA macro or subroutine in Word and save it in the Global macro sheet, the name of the subroutine automatically becomes a valid Word DDE command. Create a new macro by selecting “Macro” from the TOOLS menu. When the dialog box appears prompting for a macro name, enter the name: GRABDATA and then click the button labeled “Create”. Enter the following code in the macro editor window:

```

Sub GrabData()
    Dim Chan As Long, MyData As String

    Chan = DDEInitiate("WinWedge", "COM1") ' open a link to WinWedge
    MyData = DDERequest(Chan, "Field(1)") ' get the data from WinWedge
    DDETerminate Chan ' close the link

    Selection.TypeText Text:=MyData ' enter the data into the open document
    Selection.TypeParagraph ' insert a paragraph marker (hard return)
End Sub
```

After you are done entering the code select “Close” from the FILE menu to save the macro.

This example sets up the Wedge to issue a DDE command (\[GRABDATA()]) to Word after each data record is received from your serial device. This causes the GRABDATA subroutine to run which then performs a DDERequest back to the Wedge asking for the data in Field(1) in the Wedge Window. This data is returned to Word in the variable: MyData$. Once the data from the Wedge is in a variable, you can do whatever you like with it by including additional code of your own design. This example simply inserts the text in the MyData$ string variable into the open document and then inserts a paragraph marker.

### Transmitting data from Word

The following code fragment shows how to transmit a string out the serial port from Word:

```

channel = DDEInitiate("WinWedge", "COM2") ' open a link to the Wedge
DDEExecute channel, "[Sendout('Test',13)]" ' transmit "Test" and a carriage return
DDETerminate channel ' close the link
```

If you receive an error in Word with the message “Run-time error ‘438’: Object doesn’t support this property or method”, try renaming the subroutine in both Word and WinWedge.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.