Active I/O_Device in Excel:
Open a new Excel spreadsheet. First make the Controls toolbar visible, with
Viewà
ToolbarsàControls
Toolbox. This shows drop-and-drag icons
for the most common ActiveX controls, such as buttons or checkboxes, and presents a
More Controls icon. This picture
shows the toolbar, with Design Mode the first icon, Command Button
near the middle, and More Controls last.
Hold your cursor over an icon to learn its name.
Clicking the More Controls
presents a list of registered ActiveIO objects to choose from. (The SeaIO controls are registered when they are
installed.) Select ActiveIO_Device. Now drag this over your spreadsheet. A rectangular field with an oval in it will appear,
this is the control itself. Right-click this,
and select properties. This brings up the
properties box. It is possible to edit these
properties to correctly connect to your SeaIO device, by changing the property
This example uses another activeX control,
a command button. Find the
command button on the controls toolbar, and single-click it, then drag an area on your
spreadsheet. The button appears. Right click the button, and choose
Properties. A list of attributes
appears. Try changing Caption,
writing your own text in, and you will see the caption on the button on the spreadsheet
appear. Also, notice that when you clicked on
the button on the menu bar, the Design Mode button changed. The Design Mode button is used to
either edit, or run, your spreadsheet.
Now, select the More Controls
icon. The pulldown menu that appears will
list all of the controls available, probably a large number of them. Choose ActiveIO_Device Control.
Drag an area onto your screen, and an oval icon will appear.
SeaIO is now a part of your SpreadSheet.
This demo uses an easy way to demonstrate
how to attach code to the spreadsheet. There
are many other methods. Right-click on the
command button you added previously. Choose
Show Code. This will bring up the
Microsoft Visual Basic editor. Note that a
routine is already stubbed out for you , as Private Sub
CommandButton1_Click()
End Sub. This
is the routine that will be called when a user clicks on the button,
CommandButton1, which youve created.
Type in the following lines:
ActiveIo_Device1.deviceNumber = Sheet1.Cells(2, 2)
ActiveIo_Device1.SetDirection 0, 1
ActiveIo_Device1.WriteByte 0, 85, 1
Note that ActiveIo_Device1 is
the name of the SeaIo control youve added. Youve
programmed the button to read the right devicenumber, set the first port to output, and
send a byte as output. Now youre ready to run your spreadsheet.
Get out of Design Mode with the
Exit Design Mode icon on the controls tool bar.
Enter the text Device Num in cell A2.
Put the devicenumber of your SeaIO device, probably 2 in cell B2. Now push the button. The output should appear on port 1. The example onoff.xls carries these commands a
little further.
|