[MS-VBAL]: VBA Language Specification

2y ago
66 Views
7 Downloads
5.64 MB
287 Pages
Last View : 16d ago
Last Download : 3m ago
Upload by : Julius Prosser
Transcription

[MS-VBAL]:VBA Language SpecificationIntellectual Property Rights Notice for Open Specifications Documentation Technical Documentation. Microsoft publishes Open Specifications documentation (“thisdocumentation”) for protocols, file formats, data portability, computer languages, and standardssupport. Additionally, overview documents cover inter-protocol relationships and interactions.Copyrights. This documentation is covered by Microsoft copyrights. Regardless of any otherterms that are contained in the terms of use for the Microsoft website that hosts thisdocumentation, you can make copies of it in order to develop implementations of the technologiesthat are described in this documentation and can distribute portions of it in your implementationsthat use these technologies or in your documentation as necessary to properly document theimplementation. You can also distribute in your implementation, with or without modification, anyschemas, IDLs, or code samples that are included in the documentation. This permission alsoapplies to any documents that are referenced in the Open Specifications documentation.No Trade Secrets. Microsoft does not claim any trade secret rights in this documentation.Patents. Microsoft has patents that might cover your implementations of the technologiesdescribed in the Open Specifications documentation. Neither this notice nor Microsoft's delivery ofthis documentation grants any licenses under those patents or any other Microsoft patents.However, a given Open Specifications document might be covered by the Microsoft OpenSpecifications Promise or the Microsoft Community Promise. If you would prefer a written license,or if the technologies described in this documentation are not covered by the Open SpecificationsPromise or Community Promise, as applicable, patent licenses are available by contactingiplg@microsoft.com.License Programs. To see all of the protocols in scope under a specific license program and theassociated patents, visit the Patent Map.Trademarks. The names of companies and products contained in this documentation might becovered by trademarks or similar intellectual property rights. This notice does not grant anylicenses under those rights. For a list of Microsoft trademarks, visitwww.microsoft.com/trademarks.Fictitious Names. The example companies, organizations, products, domain names, emailaddresses, logos, people, places, and events that are depicted in this documentation are fictitious.No association with any real company, organization, product, domain name, email address, logo,person, place, or event is intended or should be inferred.Reservation of Rights. All other rights are reserved, and this notice does not grant any rights otherthan as specifically described above, whether by implication, estoppel, or otherwise.Tools. The Open Specifications documentation does not require the use of Microsoft programmingtools or programming environments in order for you to develop an implementation. If you have accessto Microsoft programming tools and environments, you are free to take advantage of them. CertainOpen Specifications documents are intended for use in conjunction with publicly available standardsspecifications and network programming art and, as such, assume that the reader either is familiarwith the aforementioned material or has immediate access to it.Support. For questions and support, please contact dochelp@microsoft.com.1 / 287[MS-VBAL] - v20210216VBA Language SpecificationCopyright 2021 Microsoft CorporationRelease: February 16, 2021

Revision 9MajorFirst release. Additional indexing and cross referencing as well asminor editorial and technical edits anticipated prior to 1.0 release.6/30/20090.95MajorUpdated to include preliminary information on the VBA languagefrom the pre-release version of VBA 7.3/15/20101.0MajorUpdated to include information on the VBA language as of VBA 7.3/15/20121.01MajorUpdated to include information on the VBA language as of VBA 7.1,as shipped in the Office 15 Technical Preview.4/30/20141.02EditorialRevised and edited technical content.12/15/20161.02NoneNo changes to the meaning, language, or formatting of thetechnical content.6/18/20191.3MinorClarified the meaning of the technical content.9/24/20191.4MinorClarified the meaning of the technical content.8/18/20201.5MinorClarified the meaning of the technical content.11/17/20201.6MinorClarified the meaning of the technical content.2/16/20211.7MinorClarified the meaning of the technical content.Comments2 / 287[MS-VBAL] - v20210216VBA Language SpecificationCopyright 2021 Microsoft CorporationRelease: February 16, 2021

Table of Contents1Introduction . 111.1Glossary . 111.2References . 111.2.1Normative References . 111.2.2Informative References . 111.3VBA Language Specification Overview . 121.4Specification Conventions . 122VBA Computational Environment . 142.1Data Values and Value Types . 142.1.1Aggregate Data Values . 162.2Entities and Declared Types. 172.3Variables. 192.3.1Aggregate Variables . 202.4Procedures . 212.5Objects . 212.5.1Automatic Object Instantiation . 222.6Projects . 222.7Extended Environment . 222.7.1The VBA Standard Library . 222.7.2External Variables, Procedures, and Objects . 232.7.3Host Environment . 233Lexical Rules for VBA Programs . 243.1Character Encodings . 243.2Module Line Structure . 243.2.1Physical Line Grammar . 243.2.2Logical Line Grammar . 253.3Lexical Tokens . 253.3.1Separator and Special Tokens . 253.3.2Number Tokens . 263.3.3Date Tokens. 303.3.4String Tokens . 323.3.5Identifier Tokens . 333.3.5.1Non-Latin Identifiers. 333.3.5.1.1Japanese Identifiers . 343.3.5.1.2Korean Identifiers . 343.3.5.1.3Simplified Chinese Identifiers . 353.3.5.1.4Traditional Chinese Identifiers . 353.3.5.2Reserved Identifiers and IDENTIFIER . 353.3.5.3Special Identifier Forms . 373.4Conditional Compilation . 383.4.1Conditional Compilation Const Directive . 383.4.2Conditional Compilation If Directives . 394VBA Program Organization . 414.1Projects . 414.2Modules . 414.2.1Module Extensibility . 435Module Bodies . 445.1Module Body Structure . 445.2Module Declaration Section Structure . 445.2.1Option Directives . 455.2.1.1Option Compare Directive . 455.2.1.2Option Base Directive . 453 / 287[MS-VBAL] - v20210216VBA Language SpecificationCopyright 2021 Microsoft CorporationRelease: February 16, 2021

5.2.1.3Option Explicit Directive . 465.2.1.4Option Private Directive . 465.2.2Implicit Definition Directives . 475.2.3Module Declarations . 485.2.3.1Module Variable Declaration Lists . 485.2.3.1.1Variable Declarations . 505.2.3.1.2WithEvents Variable Declarations . 515.2.3.1.3Array Dimensions and Bounds . 515.2.3.1.4Variable Type Declarations . 525.2.3.1.5Implicit Type Determination . 535.2.3.2Const Declarations . 535.2.3.3User Defined Type Declarations . 545.2.3.4Enum Declarations . 555.2.3.5External Procedure Declaration . 575.2.3.6Circular Module Dependencies . 585.2.4Class Module Declarations. 585.2.4.1Non-Syntactic Class Characteristics . 585.2.4.1.1Class Accessibility and Instancing . 585.2.4.1.2Default Instance Variables Static Semantics. 595.2.4.2Implements Directive . 595.2.4.3Event Declaration. 605.3Module Code Section Structure . 615.3.1Procedure Declarations . 625.3.1.1Procedure Scope . 635.3.1.2Static Procedures . 645.3.1.3Procedure Names . 645.3.1.4Function Type Declarations . 645.3.1.5Parameter Lists. 655.3.1.6Subroutine and Function Declarations . 675.3.1.7Property Declarations . 675.3.1.8Event Handler Declarations . 685.3.1.9Implemented Name Declarations . 695.3.1.10Lifecycle Handler Declarations . 705.3.1.11Procedure Invocation Argument Processing . 705.4Procedure Bodies and Statements . 735.4.1Statement Blocks . 735.4.1.1Statement Labels . 745.4.1.2Rem Statement . 745.4.2Control Statements . 745.4.2.1Call Statement. 755.4.2.2While Statement . 765.4.2.3For Statement . 765.4.2.4For Each Statement . 775.4.2.4.1Array Enumeration Order . 795.4.2.5Exit For Statement . 795.4.2.6Do Statement . 795.4.2.7Exit Do Statement . 805.4.2.8If Statement. 805.4.2.9Single-line If Statement . 815.4.2.10Select Case Statement . 825.4.2.11Stop Statement . 835.4.2.12GoTo Statement . 835.4.2.13On GoTo Statement . 835.4.2.14GoSub Statement . 845.4.2.15Return Statement . 845.4.2.16On GoSub Statement . 845.4.2.17Exit Sub Statement . 855.4.2.18Exit Function Statement . 854 / 287[MS-VBAL] - v20210216VBA Language SpecificationCopyright 2021 Microsoft CorporationRelease: February 16, 2021

5.4.2.19Exit Property Statement. 865.4.2.20RaiseEvent Statement . 865.4.2.21With Statement . 875.4.3Data Manipulation Statements . 875.4.3.1Local Variable Declarations . 875.4.3.2Local Constant Declarations. 885.4.3.3ReDim Statement. 885.4.3.4Erase Statement . 905.4.3.5Mid/MidB/Mid /MidB Statement . 905.4.3.6LSet Statement. 915.4.3.7RSet Statement . 925.4.3.8Let Statement . 925.4.3.9Set Statement . 945.4.4Error Handling Statements . 955.4.4.1On Error Statement . 965.4.4.2Resume Statement. 975.4.4.3Error Statement . 975.4.5File Statements . 975.4.5.1Open Statement . 985.4.5.1.1File Numbers .1015.4.5.2Close and Reset Statements .1025.4.5.3Seek Statement .1025.4.5.4Lock Statement .1035.4.5.5Unlock Statement .1045.4.5.6Line Input Statement .1055.4.5.7Width Statement.1055.4.5.8Print Statement .1065.4.5.8.1Output Lists .1085.4.5.9Write Statement .1085.4.5.10Input Statement .1115.4.5.11Put Statement .1125.4.5.12Get Statement .1145.5Implicit coercion .1155.5.1Let-coercion .1165.5.1.1Static semantics .1165.5.1.2Runtime semantics .1175.5.1.2.1Let-coercion between numeric types .1175.5.1.2.1.1Banker’s rounding .1185.5.1.2.2Let-coercion to and from Boolean .1185.5.1.2.3Let-coercion to and from Date .1185.5.1.2.4Let-coercion to and from String .1195.5.1.2.5Let-coercion to String * length (fixed-length strings) .1225.5.1.2.6Let-coercion to and from resizable Byte() .1235.5.1.2.7Let-coercion to and from non-Byte arrays .1245.5.1.2.8Let-coercion to and from a UDT .1245.5.1.2.9Let-coercion to and from Error .1245.5.1.2.10Let-coercion from Null .1255.5.1.2.11Let-coercion from Empty .1255.5.1.2.12Let-coercion to Variant .1265.5.1.2.13Let-coercion to and from a class or Object or Nothing .1265.5.2Set-coercion .1265.5.2.1Static semantics .1265.5.2.2Runtime semantics .1275.5.2.2.1Set-coercion to and from a class or Object or Nothing .1275.5.2.2.2Set-coercion to and from non-object types .1275.6Expressions .1285.6.1Expression Classifications .1285.6.2Expression Evaluation .1285 / 287[MS-VBAL] - v20210216VBA Language SpecificationCopyright 2021 Microsoft CorporationRelease: February 16, 2021

5.6.2.1Evaluation to a data value .1285.6.2.2Evaluation to a simple data value .1305.6.2.3Default Member Recursion Limits .1315.6.3Member Resolution .1315.6.4Expression Binding Contexts .1325.6.5Literal Expressions .1325.6.6Parenthesized Expressions .1335.6.7TypeOf Is Expressions .1335.6.8New Expressions .1335.6.9Operator Expressions .1345.6.9.1Operator Precedence and Associativity .1345.6.9.2Simple Data Operators .1355.6.9.3Arithmetic Operators .1355.6.9.3.1Unary - Operator .1395.6.9.3.2 Operator .1405.6.9.3.3Binary - Operator .1415.6.9.3.4* Operator.1425.6.9.3.5/ Operator .1435.6.9.3.6\ Operator and Mod Operator .1445.6.9.3.7 Operator .1465.6.9.4& Operator .1475.6.9.5Relational Operators .1485.6.9.5.1 Operator .1525.6.9.5.2 Operator .1525.6.9.5.3 Operator .1525.6.9.5.4 Operator .1525.6.9.5.5 Operator .1525.6.9.5.6 Operator .1535.6.9.6Like Operator .1535.6.9.7Is Operator .1555.6.9.8Logical Operators .1565.6.9.8.1Not Operator.1585.6.9.8.2And Operator .1595.6.9.8.3Or Operator .1605.6.9.8.4Xor Operator.1605.6.9.8.5Eqv Operator .1615.6.9.8.6Imp Operator .1625.6.10Simple Name Expressions .1625.6.11Instance Expressions .1655.6.12Member Access Expressions .1655.6.13Index Expressions.1675.6.13.1Argument Lists .1685.6.13.2Argument List Queues .1685.6.14Dictionary Access Expressions .1695.6.15With Expressions .1695.6.16Constrained Expressions .1695.6.16.1Constant Expressions .1695.6.16.2Conditional Compilation Expressions .1705.6.16.3Boolean Expressions .1715.6.16.4Integer Expressions.1715.6.16.5Variable Expressions .1715.6.16.6Bound Variable Expressions .1715.6.16.7Type Expressions .1715.6.16.8AddressOf Expressions.1726VBA Standard Library . 1736.1VBA Project .1736.1.1Predefined Enums .1736 / 287[MS-VBAL] - v20210216VBA Language SpecificationCopyright 2021 Microsoft CorporationRelease: February 16, 2021

6.1.1.1FormShowConstants .1736.1.1.2VbAppWinStyle .1736.1.1.3VbCalendar .1736.1.1.4VbCallType .1736.1.1.5VbCompareMethod .

Updated to include preliminary information on the VBA language from the pre-release version of VBA 7. 3/15/2010 1.0 Major Updated to include information on the VBA language as of VBA 7. 3/15/2012 1.01 Major Updated to include information on the VBA language as of VBA

Related Documents:

13.2. Excel and VBA Implementation 248 APPENDIX A VBA Programming 255 A.1 Introduction 255 A.2 A Brief History of VBA 255 A.3 Essential Excel Elements for VBA 256 A.3.1 Excel Cell Reference 257 A.3.2 Excel Defined Names 261 A.3.3 Excel Worksheet Functions 264 A.4 The VBA Development Enviro

Programming: VBA in MS Office – An Introduction 3 IT Learning Programme 1.4. What is VBA? VBA is a high-level programming language that sits behind the Microsoft Office suite of applications. It is made available, through the built-in VBA Editor in each applicable application, to the end user to create code that can be executed within

We can use VBA in all office versions right from MS-Office 97 to MS-Office 2013 and also with any of the latest versions available. Among VBA, Excel VBA is the most popular one and the reason for using VBA is that we can build very powerful tools in MS Excel using linear programming. Application of VBA

VBA4-Using Cell Formulas in VBA Page 3 of 7 O:\COURSES\VBA\Online VBA\VBA4-Using Cell Formulas in VBA.docx 8. While ActiveCell.Value "" is the way to loop as long as there is a value in the current cell. You also might use an offset: While ActiveCell.Offset(0,-1).Value "" will test the column to the left of the current column.

begin using VBA and writing a simple macro. You access VBA through Inventor using the Macro Visual Basic Editor command in the Tools menu, or by pressing Alt-F11. Once the VBA environment is open, the first thing I recommend you do is change some of the VBA settings. In the VBA environment run the Options command from the Tools menu. Change the

VBA stands for Visual Basic for Applications. It is a custom version of the venerable Visual Basic programming language that has powered Microsoft Excel's macros since the mid-1990s. IMPORTANT Please ensure any examples or topics created within the excel-vba tag are specific and relevant to the use of VBA with Microsoft Excel.

VBA The Virginia Bar Association 701 East Franklin Street, Suite 1120 Richmond, VA 23219 (804) 644-0041 FAX: (804) 644-0052 E-mail: thevba@vba.org Web: www.vba.org

No. 1 Interested in Japanese society, wanted to live in Japan 60.8% No. 2 Wanted to study the Japanese language/Japanese culture 48.2% No. 3 Found education and research at Japanese institutions, etc. appealing 34.1% No. 4 Wanted to work in an occupation connected to Japan 24.5% No. 5 Wanted to come in contact with a different culture 23.7%