macros

package
v0.0.0-...-227fc60 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 15, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package macros provides support for extracting and processing VBA macros from .doc files.

This package handles the Macros stream and VBA project structures according to the MS-DOC specification and related OLE2/VBA documentation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MacroExtractor

type MacroExtractor struct {
	// contains filtered or unexported fields
}

MacroExtractor handles extraction of VBA macros from .doc files.

func NewMacroExtractor

func NewMacroExtractor(reader *ole2.Reader) *MacroExtractor

NewMacroExtractor creates a new macro extractor for the given OLE2 reader.

func (*MacroExtractor) ExtractProject

func (me *MacroExtractor) ExtractProject() (*VBAProject, error)

ExtractProject extracts the complete VBA project from the document.

func (*MacroExtractor) HasMacros

func (me *MacroExtractor) HasMacros() bool

HasMacros checks if the document contains VBA macros.

type Module

type Module struct {
	Name       string     // Module name
	Type       ModuleType // Module type
	Code       string     // VBA source code
	Compressed bool       // True if code is compressed
	StreamName string     // Storage stream name
	Offset     uint32     // Offset within stream
	Size       uint32     // Uncompressed size
}

Module represents a VBA module (code module, class module, or form).

type ModuleType

type ModuleType int

ModuleType represents the type of VBA module.

const (
	ModuleStandard ModuleType = iota // Standard code module
	ModuleClass                      // Class module
	ModuleForm                       // UserForm module
	ModuleDocument                   // Document module (ThisDocument)
)

func (ModuleType) String

func (mt ModuleType) String() string

String returns a string representation of the module type.

type Reference

type Reference struct {
	Name        string // Reference name
	Description string // Reference description
	GUID        string // Reference GUID
	Version     string // Reference version
	Path        string // Reference file path
}

Reference represents an external reference used by the VBA project.

type VBAProject

type VBAProject struct {
	Name        string             // Project name
	Description string             // Project description
	HelpFile    string             // Help file path
	Modules     map[string]*Module // VBA modules by name
	References  []*Reference       // External references
	Protected   bool               // True if project is protected
	Password    string             // Project password (if known)
}

VBAProject represents a VBA project contained in the document.

func (*VBAProject) GetAllModuleNames

func (project *VBAProject) GetAllModuleNames() []string

GetAllModuleNames returns the names of all modules in the project.

func (*VBAProject) GetModuleCode

func (project *VBAProject) GetModuleCode(moduleName string) (string, bool)

GetModuleCode returns the VBA code for a specific module.

func (*VBAProject) GetModulesByType

func (project *VBAProject) GetModulesByType(moduleType ModuleType) []*Module

GetModuleByType returns all modules of the specified type.

func (*VBAProject) HasMacroFunctions

func (project *VBAProject) HasMacroFunctions() bool

HasMacroFunctions checks if any module contains macro functions.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL