Create a vbaProject.bin file from VBA source files.
Eventually it will be possible to use the CLI to create a vbaProject.bin file from source files and an optional configuration file.
The vbaProject class contains all the data and metadata that is used to create the OLE container. It can use this data to create several files, then compress and combine them into an OLE container
from ms_ovba.vbaProject import VbaProject
from ms_cfb.ole_file import OleFile
project = VbaProject()
thisWorkbook = DocModule("ThisWorkbook")
thisWorkbook.addFile(path)
project.addModule(thisWorkbook)
ProjectOleFile.write_file(project)The VbaProject class has many layers of customization available. For example a library reference can be added to the project.
codePage = 0x04E4
codePageName = "cp" + str(codePage)
libidRef = ReferenceRecord(codePageName, LibidReference(
"{00020430-0000-0000-C000-000000000046}",
"2.0",
"0",
"C:\\Windows\\System32\\stdole2.tlb",
"OLE Automation"
))
oleReference = Reference(codePageName, libidRef, "stdole")
project.addReference(oleReference)