Instructions
RIGOL  Chapter 4 Programming Examples 
4-4  DG2000 Programming Guide 
Remarks: 
If you cannot find VISA Library in the left section of the above dialog box, please follow the method 
below to find it. 
(1)  Make sure that your PC has installed the NI-VISA library. 
(2)  Click Browse... at the right section to search visa32.dll from C:\WINDOWS\system32, as 
shown in the figure below. 
5.  Click View Code under Developer menu to enter the interface of Microsoft Visual Basic. Add the 
following codes (the parts in green are the explanations) to the DG2000_Demo_Excel.xlsm – Sheet1 
(code) window and save it. 
Sub QueryIdn() 
 Dim viDefRm As Long 
 Dim viDevice As Long 
 Dim viErr As Long     
 Dim cmdStr As String 
 Dim idnStr As String * 128 
Dim ret As Long 
 'Turn on the device, and the device resource descriptor is in CELLS(1,2) of SHEET1' 
 viErr = visa.viOpenDefaultRM(viDefRm)   
 viErr = visa.viOpen(viDefRm, Sheet1.Cells(1, 2), 0, 5000, viDevice) 
‘Send request, read the data, and the return value is in CELLS(2,2) of SHEET1’ 
 cmdStr = "*IDN?" 
 viErr = visa.viWrite(viDevice, cmdStr, Len(cmdStr), ret)      
 viErr = visa.viRead(viDevice, idnStr, 128, ret)      
 Sheet1.Cells(2, 2) = idnStr 
‘Turn off the device’ 
 visa.viClose (viDevice) 
 visa.viClose (viDefRm) 
End Sub 
Note: If the Excel file created at Step 2 does not enable the Macros, a prompt message “The following 
features cannot be saved in macro-free workbooks” will be displayed. In this case, please save the file 
as a macro-enabled file type (filename with a suffix of ".xlsm"). 










