C H A P T E R 1 6 - C H A N G E L O G
AT5600 User Manual 98-119 issue 14 Page 415
From the Excel top level menu bar, select: Tools > Macro > Macros
Enter the name ‘OLE_Demo’ and then create.
Excel will then bring up a module sheet labeled ‘Module 1’. Type the following
code into this module sheet:
'*************************************************************************
'OLE_Demo Sub
'
'Procedure to demonstrate linking AT results into an Excel spreadsheet
'in real time using OLE.
'
'The procedure will read the third test in the program and put the result
'into a cell on the third row of the spreadsheet.
'
'The procedure will do this for a total of 3 program runs, and then exit.
Sub OLE_Demo ()
Dim objServerResult As Object
Dim vntResult(1 To 99) As Variant
Set objServerResult = CreateObject("Server.Results")
nTest = 3
nNumRuns = 3
sComPort = "COM2"
'Dummy read to clear any previous result
vntResult(nTest) = objServerResult.GetVariantResult(sComPort, nTest)
MsgBox ("Press the RUN key on the AT5600")
For nRun = 1 To nNumRuns 'Get the results
Do
vntResult(nTest) = objServerResult.GetVariantResult(sComPort, nTest)
Loop Until (vntResult(nTest) <> "NO RESULT") And _
(vntResult(nTest) <> "INVALID RESULT NUMBER")
Cells(3, 5 + nRun) = vntResult(nTest) 'Put result in spreadsheet
Next nRun
MsgBox ("Done")
End Sub
When you have finished typing the code, return to the ‘Sheet 1’ of the
spreadsheet.
To run the code, again from the Excel top-level menu bar, select: