Home
Up
Products
Surplus Parts
Specifications
How to Order
Terms and Conditions
Product Design
FAQ
Contact Us
Company
Press Release
Support
Software
International Sales

Using our Command-Line Software within Microsoft Word

This document will explain step by step, how to use the command-line software to operate our serial relay boards within Microsoft Word without knowing any software programming language.  However, we will be using visual basic for applications which is built into Word, to create some of the controls for our document.

Note: this example is tailored to a beginner without any programming experience.  Click here if you're familiar with VBA and want to jump directly to the code segment.

Let's get started:
For this demonstration we will use Word's VBA editor, but any of the software that has built in VBA support will work.  Start Word with a blank document as shown in the picture below.  Depending on which version of Word you are using and which toolbars you have open, these screens may look different.

Right click in the blank area in the toolbar area where the mouse pointer is shown. Click the Control Toolbox option button as shown in the picture below.

The control toolbox will appear as shown in the example below:  Position the mouse cursor and click  the command button as shown below.  We will add two command buttons to the document to control the ON and OFF operation of the relay boards.

When you click the button icon one command button will be displayed on the blank document with handles that will allow you to adjust the size of the button.  For now leave the button where it was placed.  The buttons in the control toolbox will all be grayed out but one.  Now click outside the command button you just placed and the control box will return to normal -- click again on the command button icon and a second button will be placed on top of the button that was already placed.  Now click and drag the top command button to the right as shown in the picture below.  These two buttons are named commandbutton1 & commandbutton2.   Due to the size of the button you may not be able to read the entire text right now..

Now right click the left hand commandbutton1 and select the properties option in the popup window.  This will display the options for the command button you just placed as shown below.  Click to the right of the property labeled caption and highlight the "commandbutton1" name and change this to

Note: Make sure you do not change the "commandbutton1" listed after (Name) by mistake as this is the name of the button not the text that is displayed on the front of the button.

The screen should now look like the following screen.

Now right click the left hand commandbutton1 and select the View Code option in the popup window.  The Visual Basic for Applications editor will load and should look similar to the picture below.  This is where we will insert the code that will control the relay operation.

Now click in the following box and select the contents of the box by holding the left mouse button and dragging down over the contents.  Hold the Ctrl Button down and press "C'' to copy the contents to the clipboard. 

Switch to Visual Basic for Applications and click inside the code window and highlight the information in the code window as shown above.  Press Ctrl "V" to paste the contents overwriting the information on this screen, the window should now look like the following picture.

The code we pasted into the window will shell out (run) the command-line software to activate all relays on the connected relay board.  This may be one of our 1, 2 or 8 channel serial relay boards that is set to address "A".  When the "All Relays ON" button (commandbutton1) is pressed the command-line software is run and the code " /AH0" is sent to the software which instructs the relay board to turn on all the relays available on this board.  See the help file in the command-line software for additional commands and instructions.

Note: The path to the software below is the default location when the command-line software is installed on a users system, if this path is different when installed this pathname will need to be changed for this example to work.

Now close this Visual Basic for Applications window and switch back to the Word Document as shown below.  Click on the depressed icon as shown in the following picture, this will exit the design mode.  Now close the control box window.

Before you run this example save the document as "relaytest.doc" or another name to preserve the editing.

Now connect up the relay board following the instructions supplied with the board, if it is not already connected.  When you press the All Relays ON button the relay board should activate all the relays, and deactivate when the other button is pressed.  If the relay board is not working, look in the command-line software troubleshooting section or online support for additional information.

Congratulations on your first Visual Basic For Applications control program!  All without requiring any mscomm32.ocx drivers or programming knowledge.  We're sure you will find many practical applications for your RS232 serial controlled relay board.

If you have any other questions you may contact the support dept at or you may request information using our feedback form.

[ Home ] [ Products ] [ Surplus Parts ] [ Terms & Conditions ] [ How To Order ] [ PDF Order Form ] [ HTML Order Form ]

Copyright 2000-2016 Pencom Design, Inc. All rights reserved. Made in USA