Skip to content

Add Excel and Word Objects support #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 27, 2025
Merged

Conversation

DecimalTurn
Copy link
Owner

@DecimalTurn DecimalTurn commented May 26, 2025

Added support for importing application-specific VBA objects:

  • Excel:
    • ThisWorkbook (Workbook): ThisWorkbook.cls or *.wbk.cls
    • Sheet (Worksheet): Sheet\d+.cls (where \d+ matches with any number of digits) or *.sheet.cls
  • Word:
    • ThisDocument (Document): ThisDocument.cls or *.doc.cls

Note that those objects need to be located in subdirectories /Microsoft Excel Objects and /Microsoft Word Objects respectively to be imported. This restriction will be removed when we introduce a manifest file.

New utility functions in Object-Import.ps1:

  • Introduced the Parse-Lines function to strip metadata headers from VBA files before importing.
  • Added Import-CodeToComponent, Find-VbaComponent, and application-specific functions (Import-ExcelObjects, Import-WordObjects) to handle importing.
  • Implemented the Import-ObjectCode function as a main entry point for importing objects based on the Office application type.

WIP add ThisWorkbook and Sheets support

Add Objects

Fix string replacement syntax

FIx metadata

Minor improvement to logging and error handling

re: Fix metadata

Use trimmed version for Version and Attribute

Early exit metadata parsing

Add log for count of files

re: Fix metadata

Add support for Word Document Objects

Fix syntax

Split code by using functions

re: Fix Syntax

Remove unnecessary Export-ModuleMember statement for dot-sourced functions
@DecimalTurn DecimalTurn requested a review from Copilot May 26, 2025 23:55
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds support for importing Excel and Word VBA objects by introducing test stubs, utility import functions, and integrating object import into the build script.

  • Added VBA class stubs for ThisWorkbook, Sheet1, and ThisDocument in test fixtures.
  • Created Object-Import.ps1 with parsing, component lookup, and application-specific import logic.
  • Updated Build-VBA.ps1 to dot-source Object-Import.ps1, set up object folders, and invoke the new import workflow.

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/WordDocument.docm/.../ThisDocument.doc.cls Added Word object stub for ThisDocument
tests/ExcelWorkbook.xlsm/.../ThisWorkbook.wbk.cls Added Excel workbook object stub
tests/ExcelWorkbook.xlsm/.../Sheet1.sheet.cls Added Excel worksheet object stub
tests/ExcelAddin.xlam/.../ThisWorkbook.cls Added Excel add-in workbook stub
tests/ExcelAddin.xlam/.../Sheet1.cls Added Excel add-in worksheet stub
scripts/utils/Object-Import.ps1 New utility functions for parsing and importing VBA components
scripts/Build-VBA.ps1 Integrated object import, folder setup, and updated dot-sourcing
Comments suppressed due to low confidence (3)

scripts/Build-VBA.ps1:7

  • Typo in 'utiliies'; should be 'utilities'.
# Load utiliies

scripts/utils/Object-Import.ps1:6

  • [nitpick] Add comment-based help (e.g., <# .SYNOPSIS, .PARAMETER >) for this function to improve maintainability and clarity.
function Parse-Lines {

tests/ExcelAddin.xlam/Microsoft Excel Objects/ThisWorkbook.cls:1

  • [nitpick] File extension '.cls' for ThisWorkbook differs from the '.wbk.cls' pattern used in workbook tests; consider renaming to 'ThisWorkbook.wbk.cls' for consistency.
VERSION 1.0 CLASS

@DecimalTurn DecimalTurn merged commit a857468 into main May 27, 2025
1 check passed
@DecimalTurn DecimalTurn deleted the dev-office-objects_squashed branch May 27, 2025 00:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant