Knowledge Base Ask Cody Resources



 
Can the terminal program allow read/write of data into Microsoft Excel?
Yes, here's some sample code that should help you with this. This macro takes all the text from Intellitem's session and puts it into cell (1,1) of the current worksheet:

Sub test()
On Error GoTo ErrorHandler

crlf = Chr(13) + Chr(10)

iChanNum = DDEInitiate("ITERM", "1")

iNumRows = DDERequest(iChanNum, "Rows")(1)

iNumCols = DDERequest(iChanNum, "Columns")(1)

data = ""


If iChanNum Then

For Row = 1 To iNumRows

request = "P" + Mid(Str(1 + ((Row - 1) * iNumCols)), 2) + "L" + LTrim(Str(iNumCols))

request = request + crlf

r = DDERequest(iChanNum, request)(1)

data = data + r

Next Row


ThisWorkbook.ActiveSheet.Cells(1, 1).Value = data



Else 'could not open session

MsgBox "Could not open DDE Session with program."

End If

ErrorHandler:

DDETerminate iChanNum

End Sub









04/20/2024   Legal notices | PRIVACY Policy |