From 322e0bba89216c85a7125495741cad3994e5be21 Mon Sep 17 00:00:00 2001 From: Martin Leduc <31558169+DecimalTurn@users.noreply.github.com> Date: Sat, 24 May 2025 22:36:35 +0000 Subject: [PATCH 1/2] Add Excel and Word objects support 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 --- scripts/Build-VBA.ps1 | 50 ++- scripts/utils/Object-Import.ps1 | 313 ++++++++++++++++++ .../Microsoft Excel Objects/Sheet1.sheet.cls | 14 + .../ThisWorkbook.wbk.cls | 14 + .../ThisDocument.doc.cls | 14 + 5 files changed, 398 insertions(+), 7 deletions(-) create mode 100644 scripts/utils/Object-Import.ps1 create mode 100644 tests/ExcelWorkbook.xlsm/Microsoft Excel Objects/Sheet1.sheet.cls create mode 100644 tests/ExcelWorkbook.xlsm/Microsoft Excel Objects/ThisWorkbook.wbk.cls create mode 100644 tests/WordDocument.docm/Microsoft Word Objects/ThisDocument.doc.cls diff --git a/scripts/Build-VBA.ps1 b/scripts/Build-VBA.ps1 index 2a56a0c..8cf112e 100644 --- a/scripts/Build-VBA.ps1 +++ b/scripts/Build-VBA.ps1 @@ -7,6 +7,8 @@ # Load utiliies $scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Path . "$scriptPath/utils/Screenshot.ps1" +. "$scriptPath/utils/Path.ps1" +. "$scriptPath/utils/Object-Import.ps1" # Args $folderName = $args[0] @@ -22,10 +24,6 @@ if (-not $officeAppName) { exit 1 } -# Import utility functions -$scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Path -. "$scriptPath/utils/Path.ps1" - $currentDir = (Get-Location).Path + "/" $srcDir = GetAbsPath -path $folderName -basePath $currentDir @@ -134,6 +132,14 @@ Write-Host "Module folder path: $moduleFolder" $classModulesFolder = GetAbsPath -path "$folderName/Class Modules" -basePath $currentDir Write-Host "Class Modules folder path: $classModulesFolder" +# Define Microsoft Excel Objects folder path +$excelObjectsFolder = GetAbsPath -path "$folderName/Microsoft Excel Objects" -basePath $currentDir +Write-Host "Microsoft Excel Objects folder path: $excelObjectsFolder" + +# Define Microsoft Word Objects folder path +$wordObjectsFolder = GetAbsPath -path "$folderName/Microsoft Word Objects" -basePath $currentDir +Write-Host "Microsoft Word Objects folder path: $wordObjectsFolder" + # Define the forms folder path $formsFolder = GetAbsPath -path "$folderName/Forms" -basePath $currentDir Write-Host "Forms folder path: $formsFolder" @@ -159,6 +165,20 @@ if (-not (Test-Path $formsFolder)) { Write-Host "Created forms folder: $formsFolder" } +#Check if the Microsoft Excel Objects folder does not exist create an empty one (only for Excel) +if ($officeAppName -eq "Excel" -and (-not (Test-Path $excelObjectsFolder))) { + Write-Host "Microsoft Excel Objects folder not found: $excelObjectsFolder" + New-Item -ItemType Directory -Path $excelObjectsFolder -Force | Out-Null + Write-Host "Created Microsoft Excel Objects folder: $excelObjectsFolder" +} + +#Check if the Microsoft Word Objects folder does not exist create an empty one (only for Word) +if ($officeAppName -eq "Word" -and (-not (Test-Path $wordObjectsFolder))) { + Write-Host "Microsoft Word Objects folder not found: $wordObjectsFolder" + New-Item -ItemType Directory -Path $wordObjectsFolder -Force | Out-Null + Write-Host "Created Microsoft Word Objects folder: $wordObjectsFolder" +} + # Get VBProject once and reuse it for all imports $vbProject = $null try { @@ -199,7 +219,25 @@ try { exit 1 } -# Import class modules first (.cls files) +# Check if we have application-specific objects to import +$objectsFolder = $null +if ($officeAppName -eq "Excel") { + $objectsFolder = $excelObjectsFolder +} elseif ($officeAppName -eq "Word") { + $objectsFolder = $wordObjectsFolder +} + +if ($objectsFolder -and (Test-Path $objectsFolder)) { + $importResult = Import-ObjectCode -officeAppName $officeAppName -vbProject $vbProject -objectsFolder $objectsFolder -screenshotDir $screenshotDir -fileNameNoExt $fileNameNoExt + + if (-not $importResult) { + Write-Host "🔴 Error: Failed to import $officeAppName object code" + Take-Screenshot -OutputPath "${screenshotDir}Screenshot_${fileNameNoExt}_{{timestamp}}.png" + exit 1 + } +} + +# Import class modules (.cls files) $clsFiles = Get-ChildItem -Path $classModulesFolder -Filter *.cls -ErrorAction SilentlyContinue Write-Host "Found $($clsFiles.Count) .cls files to import" @@ -360,5 +398,3 @@ try { } catch { Write-Host "Warning: Error releasing document COM object: $($_.Exception.Message)" } - - diff --git a/scripts/utils/Object-Import.ps1 b/scripts/utils/Object-Import.ps1 new file mode 100644 index 0000000..0d3686a --- /dev/null +++ b/scripts/utils/Object-Import.ps1 @@ -0,0 +1,313 @@ +# Summary: +# This script contains utility functions for importing VBA code into Office documents +# with special handling for application-specific object files. + +# Function to strip metadata headers from VBA class files +function Parse-Lines { + param ( + [string]$rawFileContent + ) + + # Process raw code to remove headers and metadata + $lines = $rawFileContent -split [System.Environment]::NewLine + $processedLinesList = New-Object System.Collections.Generic.List[string] + $insideBeginEndBlock = $false + $metadataHeaderProcessed = $false # Flag to indicate metadata section is passed + + foreach ($line in $lines) { + if ($metadataHeaderProcessed) { + $processedLinesList.Add($line) + continue + } + + $trimmedLine = $line.Trim() + if ($trimmedLine -eq "BEGIN") { $insideBeginEndBlock = $true; continue } + if ($insideBeginEndBlock -and $trimmedLine -eq "END") { $insideBeginEndBlock = $false; continue } + if ($insideBeginEndBlock) { continue } + if ($trimmedLine -match "^VERSION\s") { continue } + if ($trimmedLine -match "^Attribute\sVB_") { continue } + + # If none of the above, we're past the metadata header + $metadataHeaderProcessed = $true + $processedLinesList.Add($line) # Add this first non-metadata line + } + + return $processedLinesList -join [System.Environment]::NewLine +} + +# Function to import code into a VBA component +function Import-CodeToComponent { + param ( + $component, + [string]$processedCode, + [string]$componentName + ) + + try { + # Clear existing code and import new code + $codeModule = $component.CodeModule + if ($codeModule.CountOfLines -gt 0) { + $codeModule.DeleteLines(1, $codeModule.CountOfLines) + Write-Host "Cleared existing code from $componentName component" + } + + $codeModule.AddFromString($processedCode) + Write-Host "Successfully imported code into $componentName component" + return $true + } catch { + Write-Host "Error importing $componentName code: $($_.Exception.Message)" + + # Fallback to line-by-line import + try { + Write-Host "Attempting line-by-line import for $componentName..." + $processedLines = $processedCode -split [System.Environment]::NewLine + + # Ensure $codeModule is available; it should be from the outer try's assignment + if ($null -ne $codeModule) { + if ($codeModule.CountOfLines -gt 0) { + $codeModule.DeleteLines(1, $codeModule.CountOfLines) + } + + $lineIndex = 1 + foreach ($line in $processedLines) { + $codeModule.InsertLines($lineIndex, $line) + $lineIndex++ + } + Write-Host "Successfully imported $componentName code line by line" + return $true + } else { + Write-Host "Error: CodeModule for $componentName is null in fallback." + return $false + } + } catch { + Write-Host "Failed line-by-line import for ${componentName}: $($_.Exception.Message)" + return $false + } + } +} + +# Function to find a component by name in a VBA project +function Find-VbaComponent { + param ( + $vbProject, + [string]$componentName + ) + + foreach ($component in $vbProject.VBComponents) { + if ($component.Name -eq $componentName) { + Write-Host "Found $componentName component in VBA project" + return $component + } + } + + Write-Host "Error: Could not find $componentName component in VBA project" + return $null +} + +# Function to import Excel-specific objects +function Import-ExcelObjects { + param ( + $vbProject, + [string]$excelObjectsFolder, + [string]$screenshotDir, + [string]$fileNameNoExt + ) + + if (-not (Test-Path $excelObjectsFolder)) { + Write-Host "Excel Objects folder not found: $excelObjectsFolder" + return + } + + Write-Host "Importing Excel-specific objects from: $excelObjectsFolder" + + # Find ThisWorkbook.wbk.cls in the Excel Objects folder + $excelObjectsFiles = Get-ChildItem -Path $excelObjectsFolder -Filter *.cls -ErrorAction SilentlyContinue + $thisWorkbookFile = $excelObjectsFiles | Where-Object { $_.Name -eq "ThisWorkbook.wbk.cls" } + + $wbkFileCount = 0 + if ($null -ne $thisWorkbookFile) { $wbkFileCount = 1 } + Write-Host "Found $wbkFileCount .wbk.cls files to import" + + if ($null -ne $thisWorkbookFile) { + # Find the ThisWorkbook component in the VBA project + $thisWorkbookComponent = Find-VbaComponent -vbProject $vbProject -componentName "ThisWorkbook" + + if ($null -eq $thisWorkbookComponent) { + # Capture screenshot and exit if component not found + Take-Screenshot -OutputPath "${screenshotDir}Screenshot_${fileNameNoExt}_{{timestamp}}.png" + return $false + } + + # Get the code from the ThisWorkbook file + $rawFileContent = Get-Content -Path $thisWorkbookFile.FullName -Raw + + # Process raw code to remove headers and metadata + $processedCode = Parse-Lines -rawFileContent $rawFileContent + Write-Host "Processing ThisWorkbook code with $($rawFileContent.Split("`n").Count) lines" + + # Import the code into the component + $importSuccess = Import-CodeToComponent -component $thisWorkbookComponent -processedCode $processedCode -componentName "ThisWorkbook" + if (-not $importSuccess) { + return $false + } + } + + # Import Sheet objects from Excel Objects folder (only files ending with .sheet.cls) + $sheetFiles = $excelObjectsFiles | Where-Object { $_.Name -like "*.sheet.cls" } + + Write-Host "Found $($sheetFiles.Count) .sheet.cls files to import" + + foreach ($sheetFile in $sheetFiles) { + Write-Host "Processing Excel sheet object: $($sheetFile.Name)" + + # Extract the sheet name from the filename (e.g., Sheet1.sheet.cls -> Sheet1) + $sheetName = [System.IO.Path]::GetFileNameWithoutExtension($sheetFile.Name) + $sheetName = $sheetName -replace "\.sheet$", "" + + # Find the corresponding sheet component + $sheetComponent = Find-VbaComponent -vbProject $vbProject -componentName $sheetName + + # If the sheet component is not found, return an error + if ($null -eq $sheetComponent) { + Take-Screenshot -OutputPath "${screenshotDir}Screenshot_${fileNameNoExt}_{{timestamp}}.png" + return $false + } + + # Get the code from the sheet file + $rawFileContent = Get-Content -Path $sheetFile.FullName -Raw + + # Process raw code to remove headers and metadata + $processedCode = Parse-Lines -rawFileContent $rawFileContent + Write-Host "Processing sheet code with $($rawFileContent.Split("`n").Count) lines for $sheetName" + + # Import the code into the component + $importSuccess = Import-CodeToComponent -component $sheetComponent -processedCode $processedCode -componentName $sheetName + if (-not $importSuccess) { + return $false + } + } + + return $true +} + +# Function to import Word-specific objects +function Import-WordObjects { + param ( + $vbProject, + [string]$wordObjectsFolder, + [string]$screenshotDir, + [string]$fileNameNoExt + ) + + if (-not (Test-Path $wordObjectsFolder)) { + Write-Host "Word Objects folder not found: $wordObjectsFolder" + return + } + + Write-Host "Importing Word-specific objects from: $wordObjectsFolder" + + # Find ThisDocument.doc.cls in the Word Objects folder + $wordObjectsFiles = Get-ChildItem -Path $wordObjectsFolder -Filter *.cls -ErrorAction SilentlyContinue + $thisDocumentFile = $wordObjectsFiles | Where-Object { $_.Name -eq "ThisDocument.doc.cls" } + + $docFileCount = 0 + if ($null -ne $thisDocumentFile) { $docFileCount = 1 } + Write-Host "Found $docFileCount .doc.cls files to import" + + if ($null -ne $thisDocumentFile) { + # Find the ThisDocument component in the VBA project + $thisDocumentComponent = Find-VbaComponent -vbProject $vbProject -componentName "ThisDocument" + + if ($null -eq $thisDocumentComponent) { + # Capture screenshot and exit if component not found + Take-Screenshot -OutputPath "${screenshotDir}Screenshot_${fileNameNoExt}_{{timestamp}}.png" + return $false + } + + # Get the code from the ThisDocument file + $rawFileContent = Get-Content -Path $thisDocumentFile.FullName -Raw + + # Process raw code to remove headers and metadata + $processedCode = Parse-Lines -rawFileContent $rawFileContent + Write-Host "Processing ThisDocument code with $($rawFileContent.Split("`n").Count) lines" + + # Import the code into the component + $importSuccess = Import-CodeToComponent -component $thisDocumentComponent -processedCode $processedCode -componentName "ThisDocument" + if (-not $importSuccess) { + return $false + } + } + + # Look for other potential Word objects to import + $otherWordFiles = $wordObjectsFiles | Where-Object { $_.Name -ne "ThisDocument.doc.cls" } + + Write-Host "Found $($otherWordFiles.Count) other Word object files to import" + + foreach ($wordFile in $otherWordFiles) { + Write-Host "Processing Word object: $($wordFile.Name)" + + # Extract the component name from the filename (e.g., SomeObject.doc.cls -> SomeObject) + $objectName = [System.IO.Path]::GetFileNameWithoutExtension($wordFile.Name) + $objectName = $objectName -replace "\.doc$", "" + + # Try to find corresponding component if it exists + $objectComponent = Find-VbaComponent -vbProject $vbProject -componentName $objectName + + # If component doesn't exist, we'll need to try importing as a regular component + if ($null -eq $objectComponent) { + Write-Host "Component $objectName not found in VBA project, attempting to import as a regular component" + try { + $vbProject.VBComponents.Import($wordFile.FullName) + Write-Host "Successfully imported $($wordFile.Name) as a new component" + continue + } catch { + Write-Host "Error importing $($wordFile.Name): $($_.Exception.Message)" + continue + } + } + + # Get the code from the file + $rawFileContent = Get-Content -Path $wordFile.FullName -Raw + + # Process raw code to remove headers and metadata + $processedCode = Parse-Lines -rawFileContent $rawFileContent + + # Import the code into the component + $importSuccess = Import-CodeToComponent -component $objectComponent -processedCode $processedCode -componentName $objectName + if (-not $importSuccess) { + # We'll continue with other files even if one fails + Write-Host "Warning: Failed to import $objectName, continuing with other files" + } + } + + return $true +} + +# Main function to import application-specific objects +function Import-ObjectCode { + param ( + [string]$officeAppName, + $vbProject, + [string]$objectsFolder, + [string]$screenshotDir, + [string]$fileNameNoExt + ) + + Write-Host "Starting import of $officeAppName object code" + + switch ($officeAppName) { + "Excel" { + return Import-ExcelObjects -vbProject $vbProject -excelObjectsFolder $objectsFolder -screenshotDir $screenshotDir -fileNameNoExt $fileNameNoExt + } + "Word" { + return Import-WordObjects -vbProject $vbProject -wordObjectsFolder $objectsFolder -screenshotDir $screenshotDir -fileNameNoExt $fileNameNoExt + } + default { + Write-Host "No specific object handling for $officeAppName" + return $true + } + } +} + +# When this script is dot-sourced, functions are automatically available to the caller +# No need for Export-ModuleMember in a .ps1 file diff --git a/tests/ExcelWorkbook.xlsm/Microsoft Excel Objects/Sheet1.sheet.cls b/tests/ExcelWorkbook.xlsm/Microsoft Excel Objects/Sheet1.sheet.cls new file mode 100644 index 0000000..c05eca0 --- /dev/null +++ b/tests/ExcelWorkbook.xlsm/Microsoft Excel Objects/Sheet1.sheet.cls @@ -0,0 +1,14 @@ +VERSION 1.0 CLASS +BEGIN + MultiUse = -1 'True +END +Attribute VB_Name = "Sheet1" +Attribute VB_GlobalNameSpace = False +Attribute VB_Creatable = False +Attribute VB_PredeclaredId = True +Attribute VB_Exposed = True +Option Explicit + +Sub test() + Debug.Print "test" +End Sub diff --git a/tests/ExcelWorkbook.xlsm/Microsoft Excel Objects/ThisWorkbook.wbk.cls b/tests/ExcelWorkbook.xlsm/Microsoft Excel Objects/ThisWorkbook.wbk.cls new file mode 100644 index 0000000..9f739ea --- /dev/null +++ b/tests/ExcelWorkbook.xlsm/Microsoft Excel Objects/ThisWorkbook.wbk.cls @@ -0,0 +1,14 @@ +VERSION 1.0 CLASS +BEGIN + MultiUse = -1 'True +END +Attribute VB_Name = "ThisWorkbook" +Attribute VB_GlobalNameSpace = False +Attribute VB_Creatable = False +Attribute VB_PredeclaredId = True +Attribute VB_Exposed = True +Option Explicit + +Sub WriteToImmediateWindow() + Debug.Print "test" +End Sub diff --git a/tests/WordDocument.docm/Microsoft Word Objects/ThisDocument.doc.cls b/tests/WordDocument.docm/Microsoft Word Objects/ThisDocument.doc.cls new file mode 100644 index 0000000..52fa71c --- /dev/null +++ b/tests/WordDocument.docm/Microsoft Word Objects/ThisDocument.doc.cls @@ -0,0 +1,14 @@ +VERSION 1.0 CLASS +BEGIN + MultiUse = -1 'True +END +Attribute VB_Name = "ThisDocument" +Attribute VB_GlobalNameSpace = False +Attribute VB_Creatable = False +Attribute VB_PredeclaredId = True +Attribute VB_Exposed = True +Option Explicit + +Sub test() + Debug.Print "test" +End Sub From fd5a7e33cfb273507f8d702245f80c63aab9a85a Mon Sep 17 00:00:00 2001 From: Martin Leduc <31558169+DecimalTurn@users.noreply.github.com> Date: Mon, 26 May 2025 23:50:39 +0000 Subject: [PATCH 2/2] Add support for default object file names --- scripts/utils/Object-Import.ps1 | 42 ++++++++++++------- .../Microsoft Excel Objects/Sheet1.cls | 14 +++++++ .../Microsoft Excel Objects/ThisWorkbook.cls | 14 +++++++ .../Microsoft Excel Objects/Sheet1.sheet.cls | 2 +- .../ThisDocument.doc.cls | 2 +- 5 files changed, 58 insertions(+), 16 deletions(-) create mode 100644 tests/ExcelAddin.xlam/Microsoft Excel Objects/Sheet1.cls create mode 100644 tests/ExcelAddin.xlam/Microsoft Excel Objects/ThisWorkbook.cls diff --git a/scripts/utils/Object-Import.ps1 b/scripts/utils/Object-Import.ps1 index 0d3686a..d6189b2 100644 --- a/scripts/utils/Object-Import.ps1 +++ b/scripts/utils/Object-Import.ps1 @@ -120,13 +120,15 @@ function Import-ExcelObjects { Write-Host "Importing Excel-specific objects from: $excelObjectsFolder" - # Find ThisWorkbook.wbk.cls in the Excel Objects folder + # Find ThisWorkbook files in the Excel Objects folder (support multiple naming patterns) $excelObjectsFiles = Get-ChildItem -Path $excelObjectsFolder -Filter *.cls -ErrorAction SilentlyContinue - $thisWorkbookFile = $excelObjectsFiles | Where-Object { $_.Name -eq "ThisWorkbook.wbk.cls" } + $thisWorkbookFile = $excelObjectsFiles | Where-Object { + $_.Name -eq "ThisWorkbook.wbk.cls" -or $_.Name -eq "ThisWorkbook.cls" + } | Select-Object -First 1 $wbkFileCount = 0 if ($null -ne $thisWorkbookFile) { $wbkFileCount = 1 } - Write-Host "Found $wbkFileCount .wbk.cls files to import" + Write-Host "Found $wbkFileCount ThisWorkbook files to import" if ($null -ne $thisWorkbookFile) { # Find the ThisWorkbook component in the VBA project @@ -152,17 +154,25 @@ function Import-ExcelObjects { } } - # Import Sheet objects from Excel Objects folder (only files ending with .sheet.cls) - $sheetFiles = $excelObjectsFiles | Where-Object { $_.Name -like "*.sheet.cls" } + # Import Sheet objects from Excel Objects folder (support multiple naming patterns) + $sheetFiles = $excelObjectsFiles | Where-Object { + $_.Name -like "*.sheet.cls" -or ($_.Name -match "^Sheet\d+\.cls$") + } - Write-Host "Found $($sheetFiles.Count) .sheet.cls files to import" + Write-Host "Found $($sheetFiles.Count) sheet files to import" foreach ($sheetFile in $sheetFiles) { Write-Host "Processing Excel sheet object: $($sheetFile.Name)" - # Extract the sheet name from the filename (e.g., Sheet1.sheet.cls -> Sheet1) - $sheetName = [System.IO.Path]::GetFileNameWithoutExtension($sheetFile.Name) - $sheetName = $sheetName -replace "\.sheet$", "" + # Extract the sheet name from the filename based on pattern + $sheetName = "" + if ($sheetFile.Name -like "*.sheet.cls") { + $sheetName = [System.IO.Path]::GetFileNameWithoutExtension($sheetFile.Name) + $sheetName = $sheetName -replace "\.sheet$", "" + } else { + # For Sheet1.cls pattern + $sheetName = [System.IO.Path]::GetFileNameWithoutExtension($sheetFile.Name) + } # Find the corresponding sheet component $sheetComponent = Find-VbaComponent -vbProject $vbProject -componentName $sheetName @@ -206,13 +216,15 @@ function Import-WordObjects { Write-Host "Importing Word-specific objects from: $wordObjectsFolder" - # Find ThisDocument.doc.cls in the Word Objects folder + # Find ThisDocument files in the Word Objects folder (support multiple naming patterns) $wordObjectsFiles = Get-ChildItem -Path $wordObjectsFolder -Filter *.cls -ErrorAction SilentlyContinue - $thisDocumentFile = $wordObjectsFiles | Where-Object { $_.Name -eq "ThisDocument.doc.cls" } + $thisDocumentFile = $wordObjectsFiles | Where-Object { + $_.Name -eq "ThisDocument.doc.cls" -or $_.Name -eq "ThisDocument.cls" + } | Select-Object -First 1 $docFileCount = 0 if ($null -ne $thisDocumentFile) { $docFileCount = 1 } - Write-Host "Found $docFileCount .doc.cls files to import" + Write-Host "Found $docFileCount ThisDocument files to import" if ($null -ne $thisDocumentFile) { # Find the ThisDocument component in the VBA project @@ -239,7 +251,9 @@ function Import-WordObjects { } # Look for other potential Word objects to import - $otherWordFiles = $wordObjectsFiles | Where-Object { $_.Name -ne "ThisDocument.doc.cls" } + $otherWordFiles = $wordObjectsFiles | Where-Object { + $_.Name -ne "ThisDocument.doc.cls" -and $_.Name -ne "ThisDocument.cls" + } Write-Host "Found $($otherWordFiles.Count) other Word object files to import" @@ -248,7 +262,7 @@ function Import-WordObjects { # Extract the component name from the filename (e.g., SomeObject.doc.cls -> SomeObject) $objectName = [System.IO.Path]::GetFileNameWithoutExtension($wordFile.Name) - $objectName = $objectName -replace "\.doc$", "" + $objectName = $objectName -replace "\.doc$", "" # Remove .doc if present # Try to find corresponding component if it exists $objectComponent = Find-VbaComponent -vbProject $vbProject -componentName $objectName diff --git a/tests/ExcelAddin.xlam/Microsoft Excel Objects/Sheet1.cls b/tests/ExcelAddin.xlam/Microsoft Excel Objects/Sheet1.cls new file mode 100644 index 0000000..2b81624 --- /dev/null +++ b/tests/ExcelAddin.xlam/Microsoft Excel Objects/Sheet1.cls @@ -0,0 +1,14 @@ +VERSION 1.0 CLASS +BEGIN + MultiUse = -1 'True +END +Attribute VB_Name = "Sheet1" +Attribute VB_GlobalNameSpace = False +Attribute VB_Creatable = False +Attribute VB_PredeclaredId = True +Attribute VB_Exposed = True +Option Explicit + +Sub Test() + Debug.Print "test" +End Sub diff --git a/tests/ExcelAddin.xlam/Microsoft Excel Objects/ThisWorkbook.cls b/tests/ExcelAddin.xlam/Microsoft Excel Objects/ThisWorkbook.cls new file mode 100644 index 0000000..9f739ea --- /dev/null +++ b/tests/ExcelAddin.xlam/Microsoft Excel Objects/ThisWorkbook.cls @@ -0,0 +1,14 @@ +VERSION 1.0 CLASS +BEGIN + MultiUse = -1 'True +END +Attribute VB_Name = "ThisWorkbook" +Attribute VB_GlobalNameSpace = False +Attribute VB_Creatable = False +Attribute VB_PredeclaredId = True +Attribute VB_Exposed = True +Option Explicit + +Sub WriteToImmediateWindow() + Debug.Print "test" +End Sub diff --git a/tests/ExcelWorkbook.xlsm/Microsoft Excel Objects/Sheet1.sheet.cls b/tests/ExcelWorkbook.xlsm/Microsoft Excel Objects/Sheet1.sheet.cls index c05eca0..2b81624 100644 --- a/tests/ExcelWorkbook.xlsm/Microsoft Excel Objects/Sheet1.sheet.cls +++ b/tests/ExcelWorkbook.xlsm/Microsoft Excel Objects/Sheet1.sheet.cls @@ -9,6 +9,6 @@ Attribute VB_PredeclaredId = True Attribute VB_Exposed = True Option Explicit -Sub test() +Sub Test() Debug.Print "test" End Sub diff --git a/tests/WordDocument.docm/Microsoft Word Objects/ThisDocument.doc.cls b/tests/WordDocument.docm/Microsoft Word Objects/ThisDocument.doc.cls index 52fa71c..02c0308 100644 --- a/tests/WordDocument.docm/Microsoft Word Objects/ThisDocument.doc.cls +++ b/tests/WordDocument.docm/Microsoft Word Objects/ThisDocument.doc.cls @@ -9,6 +9,6 @@ Attribute VB_PredeclaredId = True Attribute VB_Exposed = True Option Explicit -Sub test() +Sub Test() Debug.Print "test" End Sub