Crate ovba

source ·
Expand description

An Office VBA project parser written in 100% safe Rust.

This is a (partial) implementation of the [MS-OVBA]: Office VBA File Format Structure protocol (Revision 9.1, published 2020-02-19).

The main entry point into the API is the Project type, returned by the open_project function.

Usage

Opening a project:

use std::fs::read;
use ovba::open_project;

let data = read("vbaProject.bin")?;
let project = open_project(data)?;

A more complete example that dumps an entire VBA project’s source code:

use std::fs::{read, write};
use ovba::open_project;

let data = read("vbaProject.bin")?;
let project = open_project(data)?;

for module in &project.modules {
    let src_code = project.module_source_raw(&module.name)?;
    write("./out/".to_string() + &module.name, src_code)?;
}

The API also supports low-level access to the [MS-CFB]: Compound File Binary File Format data. The following example lists all CFB entries:

use std::fs::read;
use ovba::open_project;

let data = read("vbaProject.bin")?;
let project = open_project(data)?;
for (name, path) in &project.list()? {
    println!(r#"Name: "{}"; Path: "{}""#, name, path);
}

Structs

Enums

  • Public error type.
  • Specifies the containing module’s type.
  • Specifies a reference to an Automation type library or VBA project.
  • Specifies the platform for which the VBA project is created.

Functions

Type Aliases

  • A type alias for Result<T, ovba::Error>.