VBA Programmer’s Guide - Keysight

Agilent E5061A/E5062A ENA Series RF Network Analyzers

VBA Programmer's Guide

Fourth Edition

FIRMWARE REVISIONS This manual applies directly to instruments that have the firmware revision A.03.00.

For additional information about firmware revisions, see Appendix A.

Manufacturing No. E5061-90033 February 2007

Notices

The information contained in this document is subject to change without notice. This document contains proprietary information that is protected by copyright. All rights are reserved. No part of this document may be photocopied, reproduced, or translated to another language without the prior written consent of Agilent Technologies. Microsoft?,MS-DOS?,Windows?,Visual C++?,Visual Basic?,VBA? and Excel? are registered UNIX is a registered trademark in U.S. and other countries, licensed exclusively through X/Open Company Limited.

Portions ?Copyright 1996, Microsoft Corporation. All rights reserved. ? Copyright 2004, 2005, 2006, 2007 Agilent Technologies

Manual Printing History

The manual's printing date and part number indicate its current edition. The printing date changes when a new edition is printed (minor corrections and updates that are incorporated at reprint do not cause the date to change). The manual part number changes when extensive technical changes are incorporated.

February 2004 First Edition (part number: E5061-90003)

September 2005 Second Edition (part number: E5061-90013, changes for firmeware version A.02.00)

June 2006

Third Edition (part number: E5061-90023, changes for firmeware version A.02.10)

February 2007

Fourth Edition (part number: E5061-90033, changes for firmeware version A.03.00)

2

Typeface Conventions

Sample (bold)

Boldface type is used when a term is defined or emphasized.

Sample (Italic)

Italic type is used for emphasis and for titles of manuals and other publications.

[Sample] [Sample] - Item

Indicates the hardkey whose key label is "Sample".

Indicates a series of key operations in which you press the [Sample] key, make the item called "Item" on the displayed menu blink by using the [ ] or in other ways, and then press the [Enter] key.

Sample Program Disk

A VBA sample program disk (Agilent part number: E5061-180x1) is furnished with this manual. The disk contains the sample programs used in this manual.

The customer shall have the personal, non-transferable rights to use, copy, or modify SAMPLE PROGRAMS in this manual for the customer's internal operations. The customer shall use the SAMPLE PROGRAMS solely and exclusively for their own purposes and shall not license, lease, market, or distribute the SAMPLE PROGRAMS or modification of any part thereof.

Agilent Technologies shall not be liable for the quality, performance, or behavior of the SAMPLE PROGRAMS. Agilent Technologies especially disclaims any responsibility for the operation of the SAMPLE PROGRAMS to be uninterrupted or error-free. The SAMPLE PROGRAMS are provided AS IS.

AGILENT TECHNOLOGIES DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.

Agilent Technologies shall not be liable for any infringement of any patent, trademark, copyright, or other proprietary right by the SAMPLE PROGRAMS or their use. Agilent Technologies does not warrant that the SAMPLE PROGRAMS are free from infringements of such rights of third parties. However, Agilent Technologies will not knowingly infringe or deliver software that infringes the patent, trademark, copyright, or other proprietary right of a third party.

3

NOTE

Documentation Map

The following manuals are available for the Agilent E5061A/E5062A.

? User's Guide (Part Number E5061-900x0, attached to Option ABA)

This manual describes most of the basic information needed to use the E5061A/E5062A. It provides a function overview, detailed operation procedure for each function (from preparation for measurement to analysis of measurement results), measurement examples, specifications, and supplemental information. For programming guidance on performing automatic measurement with the E5061A/E5062A, please see the Programming Manual.

? Installation and Quick Start Guide (Part Number E5061-900x1, attached to Option ABA)

This manual describes installation of the instrument after it is delivered and the basic procedures for applications and analysis. Refer to this manual when you use the E5061A/E5062A for the first time.

? Programmer's Guide (Part Number E5061-900x2, attached to Option ABA)

This manual provides programming information for performing automatic measurement with the E5061A/E5062A. It includes an outline of remote control, procedures for detecting measurement start (trigger) and end (sweep end), application programming examples, a command reference, and related information.

? VBA Programmer's Guide (Part Number E5061-900x3, attached to Option ABA)

This manual describes programming information for performing automatic measurement with internal controller. It includes an outline of VBA programming, some sample programming examples, a COM object reference, and related information.

? Option 100 Fault Location and Structural Return Loss Measurement User's Guide Supplement (Part Number E5061-900x4, attached to Option 100)

This manual describes information for using the fault location and structual return loss measurement functions.

The number position shown by "x" in the part numbers above indicates the edition number. This convention is applied to each manual, CD-ROM (for manuals), and sample programs disk issued.

4

Contents

1. Making Effective Use of This Manual Contents of This Manual. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 How To Use This Manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 Looking Up COM Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 Using Sample Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

2. Introduction to VBA Programming Introduction of the E5061A/E5062A Macro Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 An Overview of a Control System Based on the Macro Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 Implementing a Control System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 Control Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 Overview of E5061A/E5062A COM Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 About COM Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 Using COM Object to Control the E5061A/E5062A . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 Major Control Difference between COM Object and SCPI Command . . . . . . . . . . . . . . . . . . . . . . . . . . 28

3. Operation Basics of the E5061A/E5062A's VBA Displaying Visual Basic Editor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 Initial Screen of Visual Basic Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 Closing Visual Basic Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 Switching to the E5061A/E5062A Measurement Screen. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 Making a Preparation Before Coding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 A Project and Three Types of Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 Displaying a Code Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 Coding a VBA Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 User Interface Elements of a Code Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 Creating a Simple VBA Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 Auto-complete Feature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 Saving a VBA program. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 Saving a Project. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 Saving a Module (Exporting) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 Loading a VBA Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 Loading a Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 Loading a Module (Importing) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 Running a VBA Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 Running a previous loaded VBA program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 Loading and executing program in batch process. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 Stopping a VBA Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 Stopping with the Dialog Box Appeared . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 Abruptly Terminating the VBA Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 Errors and Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 Types of Error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 Using a Debug Tool. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 Printing Output Values in the Echo Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 Entering Values Output to the Echo Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 Opening the Echo Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 Clearing Values Output in the Echo Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 Using VBA Online Help. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60

5

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download