Sub SOLTCal()
'Turn off continuous sweep
GPIB.Write "INITiate:CONTinuous OFF"

'Turn off two sets of standards
GPIB.Write ":SENSe:CORRection:TSTandards OFF"

'Turn isolation acquisition on
GPIB.Write "SENSe:CORRection:ISOLation ON  

'Select 2-Port Calibration
GPIB.Write "SENSe:CORRection:COLLect:METHod SPARSOLT"

'Set acquisition to FORWARD 
GPIB.Write "SENSe:CORRection:COLLect:SFORward ON

'Select a cal kit
Calkitnum = 3
GPIB.Write "SENSe:CORRection:COLLect:CKIT:SELect " & Val(Calkitnum)

'Measure the standards in forward direction
MsgBox "Connect OPEN to Port 1; then press OK"
Call Measurestandard("stan1")

MsgBox "Connect SHORT to Port 1; then press OK"
Call Measurestandard("stan2")

MsgBox "Connect LOAD to Port 1; then press OK"
Call Measurestandard("stan3")

'Set acquisition to REVERSE
GPIB.Write "SENSe:CORRection:COLLect:SFORward OFF

'Measure the standards in reverse direction
MsgBox "Connect OPEN to Port 2; then press OK"
Call Measurestandard("stan1")

MsgBox "Connect SHORT to Port 2; then press OK"
Call Measurestandard("stan2")

MsgBox "Connect LOAD to Port 2; then press OK"
Call Measurestandard("stan3")

'Turn ON two sets of standards for Thru and Isolation standards
GPIB.Write ":SENSe:CORRection:TSTandards ON"

'Measure the thru and isolation standards
MsgBox "Connect THRU between Ports 1 and 2; then press OK"
Call Measurestandard("stan4")

MsgBox "Disconnect Ports 1 and 2 for isolation; then press OK"
Call Measurestandard("stan5")

'Compute the coefficients and turn on error correction
GPIB.Write "SENSe:CORRection:COLLect:SAVE"

'Resume continuous sweep.
GPIB.Write "INITialize:CONTinuous ON"
End Sub

Sub Measurestandard(Std$)

'Store the results of a sweep as correction data
GPIB.Write "SENSe:CORRection:COLLect " & Std$

'Take a sweep;return when complete
GPIB.Write "INITiate:IMMediate;*OPC?"
OPCreply = GPIB.Read

End Sub 
