
13.4. Function of the Excel Macro
Excel macros are programmed in Visual Basic. Via the Excel menu Tools / Macro / Visual
Basic Editor you may view and modify the source code of the VM30-H macro.
The only specific part for the VM30-H is the function declaration for RS-232 communication
which is embedded by means of the file VM30-DLL:
Declare Sub OPENCOM Lib "VM30.DLL" (ByVal COM_Parameter$)
Declare Sub CLOSECOM Lib "VM30.DLL" ()
Declare Sub TIMEOUT Lib "VM30.DLL" (ByVal ms%)
Declare Sub STRLENGTH Lib "VM30.DLL" (ByVal B%)
Declare Function STRREAD Lib "VM30.DLL" (ByVal D$) As Integer
Declare Sub SENDSTRING Lib "VM30.DLL" (ByVal S As String)
These commands have the following meaning:
OPENCOM
(Parameter$)
opens a serial interface using the parameter string in the form
„COM1:57600,E,7,1“ (COM port number, baud rate, parity, data bits, stop bits).
CLOSECOM
closes the serial interface.
TIMEOUT (ms)
is the maximum waiting time when receiving data from the serial interface in
milliseconds. Transmission is stopped if no data is received before the waiting time is over.
STRLENGTH (Length)
is the length of a character string to be received.
STRREAD (String)
receives a character string with the length defined by STRLENGTH. When
the time defined in TIMEOUT is exceeded, the function returns the string “Fehler”. The string
variable must be filled with space characters before reception.
Example:
SRLENGTH 8
Data$ = " "
STRREAD (Data$)
The program code of the VM30-H macro consists mainly of the reception of character strings
from the instrument and their interpretation and display in table fields.
Feel free to modify the macro or the Excel file according to your requirements.
SENDSTRING (String)
transmits a character string
Data is transferred only in the direction from the VM30-H to the PC after the PC has transmitted
the start character “#” by the SENDSTRING command.
36