Skip to content

Commit ee39562

Browse files
committed
Add AccessDatabase
1 parent fd37b0e commit ee39562

File tree

6 files changed

+69
-33
lines changed

6 files changed

+69
-33
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ jobs:
2727
name: "VBA-Enabled-Documents"
2828
path: "./tests/out/*"
2929
if-no-files-found: warn
30+
# TODO: Check if better method to visualize the screenshots: https://github.com/actions/upload-artifact/issues/14
3031
- name: "Upload Screenshots"
3132
# Run this step even if the build failed
3233
if: success() || failure()

Main.ps1

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,20 @@ foreach ($app in $officeApps) {
6464
foreach ($folder in $folders) {
6565
$app = Get-OfficeApp -FileExtension $folder.Substring($folder.LastIndexOf('.') + 1)
6666

67+
$ext = "zip"
6768
if ($app -ne "Access") {
6869
Write-Host "Create Zip file and rename it to Office document target"
6970
. "$PSScriptRoot/scripts/Zip-It.ps1" "${SourceDir}/${folder}"
70-
Write-Host "========================="
7171
}
72+
else {
73+
$ext = "accdb"
74+
}
75+
76+
Write-Host "Copy and rename the file to the correct name"
77+
. "$PSScriptRoot/scripts/Rename-It.ps1" "${SourceDir}/${folder}" "$ext"
7278

7379
Write-Host "Importing VBA code into Office document"
7480
. "$PSScriptRoot/scripts/Build-VBA.ps1" "${SourceDir}/${folder}" "$app"
81+
82+
Write-Host "========================="
7583
}

scripts/Rename-It.ps1

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# This scripts simply copies the file from the source to the destination folder
2+
# and renames it to the correct file name based on the folder name.
3+
4+
# Read the name of the folder from the argument passed to the script
5+
$folderName = $args[0]
6+
if (-not $folderName) {
7+
Write-Host "Error: No folder name specified. Usage: Rename-It.ps1 <FolderName>"
8+
exit 1
9+
}
10+
11+
$ext = $args[1]
12+
if (-not $ext) {
13+
Write-Host "Error: No file extension specified. Usage: Rename-It.ps1 <FolderName> <FileExtension>"
14+
exit 1
15+
}
16+
17+
$sourceDir = $folderName.Substring(0, $folderName.LastIndexOf('/'))
18+
19+
$filNameWithExtension = $folderName.Substring($folderName.LastIndexOf('/') + 1)
20+
$fileName = $filNameWithExtension.Substring(0, $filNameWithExtension.LastIndexOf('.'))
21+
$fileExtension = $filNameWithExtension.Substring($filNameWithExtension.LastIndexOf('.') + 1)
22+
23+
# Create a copy of the zip/document file in the $folderName/Skeleton folder at the top level
24+
$copySource = "$folderName/Skeleton/$fileName.$ext"
25+
$renameDestinationFolder = "$sourceDir/out"
26+
$renameDestinationFilePath = "$renameDestinationFolder/$fileName.$fileExtension"
27+
28+
# Create rename destination folder if it doesn't exist
29+
if (-not (Test-Path $renameDestinationFolder)) {
30+
Write-Host "Creating destination folder: $renameDestinationFolder"
31+
New-Item -ItemType Directory -Path $renameDestinationFolder -Force | Out-Null
32+
}
33+
34+
# Delete the destination file if it exists
35+
if (Test-Path $renameDestinationFilePath) {
36+
Write-Host "Deleting existing file: $renameDestinationFilePath"
37+
Remove-Item -Path $renameDestinationFilePath -Force
38+
}
39+
40+
# Copy and rename the file in one step
41+
Write-Host "Copying and renaming $copySource to $renameDestinationFilePath"
42+
Copy-Item -Path $copySource -Destination $renameDestinationFilePath -Force
43+
44+
# Verify if the file exists after the copy
45+
if (-not (Test-Path $renameDestinationFilePath)) {
46+
Write-Host "Error: File not found after copy: $renameDestinationFilePath"
47+
exit 1
48+
}
49+
50+
Write-Host "File successfully copied and renamed to: $renameDestinationFilePath"

scripts/Zip-It.ps1

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,14 @@ $filNameWithExtension = $folderName.Substring($folderName.LastIndexOf('/') + 1)
1313
$fileName = $filNameWithExtension.Substring(0, $filNameWithExtension.LastIndexOf('.'))
1414
$fileExtension = $filNameWithExtension.Substring($filNameWithExtension.LastIndexOf('.') + 1)
1515

16-
1716
Write-Host "Staring the compression process..."
1817

1918
$currentDir = Get-Location
2019
Write-Host "Current directory: $currentDir"
2120

2221
# Define the source folder and the output zip file
2322
$sourceFolder = Join-Path -Path $currentDir -ChildPath "$folderName/XMLsource/"
24-
$outputZipFile = Join-Path -Path $currentDir -ChildPath "$folderName/XMLoutput/$fileName.zip"
23+
$outputZipFile = Join-Path -Path $currentDir -ChildPath "$folderName/Skeleton/$fileName.zip"
2524

2625
# Path to the 7-Zip executable
2726
$sevenZipPath = "7z" # Assumes 7-Zip is in the system PATH. Adjust if necessary.
@@ -90,33 +89,3 @@ if ($LASTEXITCODE -ne 0) {
9089
}
9190

9291
Write-Host "Compression completed successfully. Zip file created at: $absoluteDestinationFolder"
93-
94-
95-
# Create a copy of the zip file in the $folderName/XMLoutput folder at the top level
96-
$copySource = "$folderName/XMLoutput/$fileName.zip"
97-
$renameDestinationFolder = "$sourceDir/out"
98-
$renameDestinationFilePath = "$renameDestinationFolder/$fileName.$fileExtension"
99-
100-
# Create rename destination folder if it doesn't exist
101-
if (-not (Test-Path $renameDestinationFolder)) {
102-
Write-Host "Creating destination folder: $renameDestinationFolder"
103-
New-Item -ItemType Directory -Path $renameDestinationFolder -Force | Out-Null
104-
}
105-
106-
# Delete the destination file if it exists
107-
if (Test-Path $renameDestinationFilePath) {
108-
Write-Host "Deleting existing file: $renameDestinationFilePath"
109-
Remove-Item -Path $renameDestinationFilePath -Force
110-
}
111-
112-
# Copy and rename the file in one step
113-
Write-Host "Copying and renaming $copySource to $renameDestinationFilePath"
114-
Copy-Item -Path $copySource -Destination $renameDestinationFilePath -Force
115-
116-
# Verify if the file exists after the copy
117-
if (-not (Test-Path $renameDestinationFilePath)) {
118-
Write-Host "Error: File not found after copy: $renameDestinationFilePath"
119-
exit 1
120-
}
121-
122-
Write-Host "File successfully copied and renamed to: $renameDestinationFilePath"
Binary file not shown.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Attribute VB_Name = "Module1"
2+
3+
'@Lang VBA
4+
Option Explicit
5+
6+
Sub Demo()
7+
MsgBox "Hello, World!"
8+
End Sub

0 commit comments

Comments
 (0)