> ## 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.

# Transmitting commands to devices from Access

> Send commands and text to your serial device from a VBA macro with WinWedge using its more advanced DDE mode.

**Note:** For a list of DDE commands, check out the support article listing [WinWedge DDE Commands](https://support.taltech.com/winwedge/winwedge-dde-comm.md).

WinWedge makes it very easy for Excel or Access to communicate with the device. This isn’t limited to simply logging data from the device to Excel or Access, but WinWedge also enables Excel or Access to send data directly from VBA using WinWedge’s “SENDOUT” and “SEND” DDE Commands

#### Sending a command to the device using sendout DDE command

The following code allows you to send any command to your device. In this example, we’re sending four characters: an ASCII 27 (an ESC character), a capital ‘P’, and a carriage return and line feed characters (ASCII 13 and 10).

```vb theme={null}
Function SendCommand()
   Dim Chan As Long
   Chan = DDEInitiate("WinWedge", "COM1")
   DDEExecute Chan, "[SENDOUT(27,'P',13,10)]"
   DDETerminate Chan
End Function
```

#### Sending a string to the device using send DDE command

If you need to send an entire string to the device, you can use the following code:

```vb theme={null}
Function SendString (StringVar$)
   Dim Chan As Long
   Chan = DDEInitiate("WinWedge", "Com1")
   DDEExecute Chan, "[SEND(" + StringVar$ + ")]"
   DDETerminate Chan' terminate the link
End Function
```

This code can even be used to send an entire table or query out the serial port:

```vb theme={null}
Sub SendQuery()
Dim chan, MyDb, MyQuery, strSend

'set database
Set MyDb = CurrentDb()

'open a table or query that holds the data you wish to send
Set MyQuery = MyDb.OpenRecordset("Deliveries")

'Open DDE Channel to WinWedge
chan = DDEInitiate("WinWedge", "COM2")

'point to first record in the table/query
MyQuery.MoveFirst

Do
strSend = "" 'reset string between records

'Generate string to send
For i = 0 To MyQuery.Fields.Count - 1
strSend = strSend & MyQuery.Fields(i) & ","
Next

'trim off last comma and replace it with CR/LF
strSend = Left(strSend, Len(strSend) - 1) & vbCrLf

'send string
DDEExecute chan, "[SEND(" + strSend + ")]"

MyQuery.MoveNext 'point to next record in the query
Loop Until MyQuery.EOF 'while (we have not reached the end of the table/query)

quit:
'close DDE channel and clean up
DDETerminate chan
Set db = Nothing
Set chan = Nothing

End Sub
```


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