API Reference
OfficeVbaProject
Reads and edits a host-neutral VBA compound project without executing or compiling its source.
Inheritance
- Object
- OfficeVbaProject
Usage
This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.
Returned or exposed by
- Method OfficeVbaProject.Create
- Method OfficeVbaProject.Load
Methods
public OfficeVbaModule AddDocumentModule(String name, String source, Guid baseClassId) #OfficeVbaModuleAdds a host-owned module whose VB_Base class identity is supplied by the document adapter.
Parameters
- name System.String
- source System.String
- baseClassId System.Guid
public OfficeVbaModule AddModule(String name, String source, OfficeVbaModuleKind kind = Standard) #OfficeVbaModuleAdds a standard or ordinary class module; host document and designer identities require their own owners.
Parameters
- name System.String
- source System.String
- kind OfficeIMO.OfficeVbaModuleKind = Standard
public Void AddRegisteredReference(String name, Guid typeLibraryId, Int32 majorVersion = 1, Int32 minorVersion = 0, String path = "") #VoidAdds a registered type-library reference without installing or executing that library.
Parameters
- name System.String
- typeLibraryId System.Guid
- majorVersion System.Int32 = 1
- minorVersion System.Int32 = 0
- path System.String = ""
public static OfficeVbaProject Create(String name = "VBAProject", Int32 codePage = 1252) #OfficeVbaProjectCreates a template-free VBA project with a native directory and source-only compilation state.
Parameters
- name System.String = "VBAProject"
- codePage System.Int32 = 1252
public Void DeleteModule(String name) #VoidDeletes a standard or class module. Host-owned and designer modules remain under their owning document.
Parameters
- name System.String
public Void ExportSources(String directory) #VoidExports UTF-8 source files and a typed XML manifest to a new directory for version control.
Parameters
- directory System.String
public OfficeVbaModule GetModule(String name) #OfficeVbaModuleGets a module by its case-insensitive logical name.
Parameters
- name System.String
public Void ImportSources(String directory, Int32 maximumSourceBytes = 67108864) #VoidImports the source files named in an exported manifest, with validation before any project mutation.
Parameters
- directory System.String
- maximumSourceBytes System.Int32 = 67108864
public static OfficeVbaProject Load(Byte[] projectBytes, OfficeVbaReadOptions options = null) #OfficeVbaProjectLoads a detached project with aggregate input, compound-stream, and expanded-source limits.
Parameters
- projectBytes System.Byte[]
- options OfficeIMO.OfficeVbaReadOptions = null
Exceptions
InvalidDataException– The project is malformed or its persisted text encoding is invalid or unavailable.
public Boolean RemoveReference(String name) #BooleanRemoves one explicit reference without rewriting source that uses its types.
Parameters
- name System.String
public Void RenameModule(String name, String newName) #VoidRenames a standard or class module and its project/stream identities; source code references are not rewritten.
Parameters
- name System.String
- newName System.String
public Void SetModuleSource(String name, String source) #VoidReplaces source while preserving module kind, attributes, and the rest of the project.
Parameters
- name System.String
- source System.String
public OfficeVbaWriteResult Write(OfficeVbaWriteOptions options = null) #OfficeVbaWriteResultProduces a bounded complete project; unchanged projects retain their original bytes and signatures.
Parameters
- options OfficeIMO.OfficeVbaWriteOptions = null
Inherited Methods
Properties
public String Name { get; } #Gets the project's persisted name.
public Int32 CodePage { get; } #Gets the Windows code page used by source and ANSI project records.
public IReadOnlyList<OfficeVbaModule> Modules { get; } #Gets the source modules in directory order.
public IReadOnlyList<OfficeVbaReference> References { get; } #Gets the project's explicit library references.
public Boolean IsProtected { get; private set; } #Gets whether the project declares password or access protection; protected projects remain readable.
public Boolean HasChanges { get; } #Gets whether editing operations differ from the loaded source project.