An open API service indexing awesome lists of open source software.

https://github.com/janmarvin/ovbars

Accesses the 'ovba' rust library to extract vba binary files
https://github.com/janmarvin/ovbars

r r-package vba

Last synced: 19 days ago
JSON representation

Accesses the 'ovba' rust library to extract vba binary files

Awesome Lists containing this project

README

        

---
output: github_document
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```

# ovbars

[![R-CMD-check](https://github.com/JanMarvin/ovbars/workflows/R-CMD-check/badge.svg)](https://github.com/JanMarvin/ovbars/actions)
[![r-universe](https://janmarvin.r-universe.dev/badges/ovbars)](https://janmarvin.r-universe.dev/ovbars)

In the Office Open XML standard, files with the `.xlsm` extension indicate that the workbook contains macros. When loading these files using R packages, the macro code is not directly visible as it is embedded in a file named `vbaProject.bin`.

This R package serves as a wrapper around the `ovba` Rust library, enabling the parsing of the `vbaProject.bin` file. You can extract the `vbaProject.bin` file by unzipping the XLSM file or by using the `openxlsx2` package, as demonstrated in the example below.

```{r}
## an example xlsm file
fl <- "https://janmarvin.github.io/openxlsx-data/gh_issue_416.xlsm"

## get the path to the vba file
vba <- openxlsx2::wb_load(fl)$vbaProject

## extract the macro code
code <- ovbars::ovbar_out(name = vba)

## access the code from "Sheet1"
message(code["Sheet1"])
```

This view differs from what you might be accustomed to in spreadsheet software, as it includes additional information typically used internally by the software. Lines starting with `Attribute` are entirely hidden.

Similarly, this project allows the extraction of additional information regarding the file system of the OVBA file.
```{r}
## additional meta information regarding the OVBA file system
ovbars::ovbar_meta(name = vba)
```

## Development
```r
# document code
savvy::savvy_update()
devtools::document()
# update vendored packages
rextendr::vendor_pkgs()
```

## License

This package is licensed under the MIT license and is based on [`ovba`](https://github.com/tim-weis/ovba) (by Tim Weis; COPYRIGHT 2020-2025), also under the MIT license.