Revision Summary Date Revision History Revision Class Comments 6/27/2008 1.0 New Initial Availability 8/15/2008 1.01 Editorial Revised and edited the technical content 1/16/2009 1.02 Editorial Revised and edited the technical content 7/13/2009 1.03 Changes made for template compliance 8/28/2009 1.04 Editorial Revised and edited the technical content 11/6/2009 1.05 Editorial Revised and edited the technical content 2/19/2010 2.0 Minor Updated the technical content 3/31/2010 2.01 Editorial Revised and edited the technical content 4/30/2010 2.02 Editorial Revised and edited the technical content 6/7/2010 2.03 Editorial Revised and edited the technical content 6/29/2010 2.04 Editorial Changed language and formatting in the technical content. 7/23/2010 2.04 None No changes to the meaning,
language, or formatting of the technical content. 9/27/2010 2.04 None No changes to the meaning, language, or formatting of the technical content. 11/15/2010 2.05 Editorial Changed language and formatting in the technical content. 12/17/2010 2.05 None No changes to the meaning, language, or formatting of the technical content. 3/18/2011 2.05 None No changes to the meaning, language, or formatting of the technical content. 6/10/2011 2.05 None No changes to the meaning, language, or formatting of the technical content. 1/20/2012 2.6 Minor Clarified the meaning of the technical content.
technical content. 4/30/2014 3.0 Major Significantly changed the technical content. 7/31/2014 3.1 Minor Clarified the meaning of the technical content. 10/30/2014 3.2 Minor Clarified the meaning of the technical content. 3/16/2015 4.0 Major Significantly changed the technical content. 9/4/2015 4.1 Minor Clarified the meaning of the technical content. 7/15/2016 4.1 None No changes to the meaning, language, or formatting of the technical content. 9/14/2016 4.1 None No changes to the meaning, language, or formatting of the technical content.
This persistence format provides interoperability with applications that create or read documents conforming to this structure<1>. Versioning and Localization This document covers versioning issues in the following areas: Structure Versions: There is only one version of the Office VBA File Format Structure. Localization: This structure defines no locale-specific processes or data. This file format contains performance caches that are not interoperable between versions. A version identifier (_VBA_PROJECT_Stream.Version, section ) is defined to keep track of the exact version that saved a VBA project. When this version number matches the version used by Office, performance caches, specified by _VBA_PROJECT.PerformanceCache (section 2.2.3), SRP Streams (section ), and Module Stream.PeformanceCache (section ), will be used instead of the interoperable representation within the file. To be interoperable, this version number must be set to 0xFFFF so that performance caches are ignored. Vendor-Extensible Fields This file format provides a mechanism for vendor extension through custom designers. For details on designers, see VBFrame Stream (section ). No mechanism is provided for generating a unique for a designer.
Structures Conventions This section uses the following conventions and common definitions for pseudocode and ABNF rule definitions. ABNF Rules This section specifies ABNF common throughout section . Common ABNF Rules The following ABNF rules are used by section and are included for reference. For more information, see Appendix B. ABNF Syntax: CR = %x0D DIGIT = %x30-39 DQUOTE = %x22 HEXDIG = DIGIT / "A" / "B" / "C" / "D" / "E" / "F" HTAB = %x09 LF = %x0A SP = %x20 VCHAR = %x21-7E WSP = SP / HTAB ANYCHAR Specifies any character value that is not a carriage-return, line-feed, or null. ABNF syntax: ANYCHAR = %x01-09 / %x0B / %x0C / %x0E-FF EQ Defines syntax for separating a property name from a value. ABNF syntax: EQ = *WSP "=" *WSP FLOAT Specifies a .
Id (2 bytes): An unsigned integer that specifies the identifier for this record. MUST be 0x0021 when the containing MODULE Record (section 2.3.4.2.3.2) is a procedural module. MUST be 0x0022 when the containing MODULE Record (section 2.3.4.2.3.2) is a document module, class module, or designer module. Reserved (4 bytes): MUST be 0x00000000. MUST be ignored. MODULEREADONLY Record Specifies that the containing MODULE Record (section ) is read-only. 0 1 2 3 4 5 6 7 8 9 1 0 1 2 3 4 5 6 7 8 9 2 0 1 2 3 4 5 6 7 8 9 3 0 1 Id Reserved ... Id (2 bytes): An unsigned integer that specifies the identifier for this record. MUST be 0x0025. Reserved (4 bytes): MUST be 0x00000000. MUST be ignored. MODULEPRIVATE Record Specifies that the containing (section 2.3.4.2.3.2) is only usable from within the current VBA project. 0 1 2 3 4 5 6 7 8 9 1 0 1 2 3 4 5 6 7 8 9 2 0 1 2 3 4 5 6 7 8 9 3 0 1 Id Reserved ... Id (2 An unsigned integer that specifies the identifier for this record. MUST be 0x0028. Reserved (4 MUST be 0x00000000. MUST be ignored. Module Stream: Visual Basic Modules Specifies the source code for a module. 0 1 2 3 4 5 6 7 8 9 1 0 1 2 3 4 5 6 7 8 9 2 0 1 2 3 4 5 6 7 8 9 3 0 1 PerformanceCache (variable) ... CompressedSourceCode (variable) ... PerformanceCache (variable): An array of bytes that forms an implementation-specific and version-dependent performance cache for the module. MUST be (section 2.3.4.2.3.2.5) bytes in size. MUST be ignored on read.
Decryption This decryption algorithm accepts an (section 2.4.3.1) as input and will yield: Length (4 bytes): An unsigned integer that specifies the length of Data. Data (variable): An array of unencrypted bytes. To decrypt Data from an Encrypted Data Structure (section 2.4.3.1), an implementation MUST maintain the following states: UnencryptedByte1 (1 byte): Specifies the last unencrypted byte read or written. EncryptedByte1 (1 byte): Specifies the last encrypted byte read or written. EncryptedByte2 (1 byte): Specifies the next-to-last encrypted byte read or written. Version (1 byte): Specifies the encryption version. ProjKey (1 byte): Specifies a project-specific encryption key. IgnoredLength (1 byte): Specifies the length in bytes of IgnoredEnc. MUST decrypt in order as follows. Version is calculated using the following formula. Version = Seed XOR VersionEnc Version MUST be 2. ProjKey is calculated the following formula. ProjKey = Seed XOR ProjKeyEnc To initialize states for the rest of the encoding: SET UnencryptedByte1 TO ProjKey. SET EncryptedByte1 TO ProjKeyEnc. SET EncryptedByte2 TO VersionEnc. The length of IgnoredEnc is computed as follows. IgnoredLength = (Seed BAND 6) / 2 Decrypting of IgnoredEnc MUST be as follows. FOR each ByteEnc IN IgnoredEnc: SET Byte TO (ByteEnc XOR (EncryptedByte2 + UnencryptedByte1)). SET EncryptedByte2 TO EncryptedByte1. SET EncryptedByte1 TO ByteEnc. SET UnencryptedByte1 TO Byte.
Project Reference Information Example The following example illustrates the (section 2.3.4.2.2) record for the VBA project. This project includes four references. Offset Structure Value - ReferenceArray - Reference[0] - NameRecord unsigned integer - Id 0x0016 unsigned integer - SizeOfName 0x00000006 array of bytes - Name stdole unsigned integer - Reserved 0x003E unsigned integer - SizeOfNameUnicode 0x0000000C array of bytes - NameUnicode stdole - ReferenceRecord[0] unsigned integer - Id 0x000D unsigned integer - Size 0x00000068 unsigned integer - SizeOfLibid 0x0000005E array of bytes - Libid Automation unsigned integer - Reserved1 0x00000000 unsigned integer - Reserved2 0x0000 REFERENCE Record - Reference[1] REFERENCENAME Record - NameRecord unsigned integer - Id 0x0016 unsigned integer - SizeOfName 0x00000006 array of bytes - Name Office unsigned integer - Reserved 0x003E 8C 6E 06 03
unsigned integer - SizeOfNameUnicode 0x0000000C of bytes - NameUnicode Office Record - ReferenceRecord[1] unsigned integer - Id 0x000D unsigned integer - Size 0x0000009E unsigned integer - SizeOfLibid 0x00000094 array of bytes - Libid Files\Common Files\Microsoft Shared\OFFICE12\MSO.DLL#Microsoft Office 12.0 Object Library unsigned integer - Reserved1 0x00000000 unsigned integer - Reserved2 0x0000 REFERENCE Record - Reference[2] REFERENCENAME Record - NameRecord unsigned integer - Id 0x0016 unsigned integer - SizeOfName 0x0000000B of bytes - Name VBAProject1 unsigned integer - Reserved 0x003E unsigned integer - SizeOfNameUnicode 0x00000016 array of bytes - NameUnicode VBAProject1 - ReferenceRecord[2] unsigned integer - Id 0x000E unsigned integer - Size 0x0000005E unsigned integer - SizeOfLibidAbsolute 0x00000030 array of bytes - LibidAbsolute *\CC:\Example Path\Example-ReferencedProject.xls unsigned integer - SizeOfLibidRelative 0x00000020 0B 30
array of bytes - LibidRelative *\CExample-ReferencedProject.xls unsigned integer - MajorVersion 0x49A95F46 unsigned integer - MinorVersion 0x000D REFERENCE Record - Reference[3] REFERENCENAME Record - NameRecord unsigned integer - Id 0x0016 unsigned integer - SizeOfName 0x00000007 array of bytes - Name MSForms unsigned integer - Reserved 0x003E unsigned integer - SizeOfNameUnicode 0x0000000E array of bytes - NameUnicode MSForms - ReferenceRecord[3] - OriginalRecord unsigned integer - Id 0x0033 unsigned integer - SizeOfLibidOriginal 0x0000006F of bytes - LibidOriginal Forms 2.0 Object Library unsigned integer - Id 0x002F unsigned integer - SizeTwiddled 0x0000003B unsigned integer - SizeOfLibidTwiddled 0x00000031 array of bytes - LibidTwiddled *\G{00000000-0000-0000-0000-000000000000}#0.0#0## unsigned integer - Reserved1 0x00000000 unsigned integer - Reserved2 0x0000 REFERENCENAME Record - 6F 75 21 21