├── .editorconfig ├── .github └── workflows │ ├── ci.yml │ └── release.yml ├── .gitignore ├── .gitmodules ├── .vscode └── tasks.json ├── LICENSE.txt ├── README.md ├── build.sh ├── sample ├── Class1.vb ├── Makefile ├── Module1.vb ├── ThisDocument.vb └── customUI │ ├── customUI14.xml │ └── images │ ├── icons8-about-96.png │ ├── icons8-contacts-96.png │ ├── icons8-home-96.png │ └── license.txt ├── src ├── Directory.Build.props ├── VbaCompiler │ ├── DirectoryEx.cs │ ├── Guard.cs │ ├── Icon.png │ ├── Internals.cs │ ├── README.md │ ├── Vba │ │ ├── Constants.cs │ │ ├── DirStream.cs │ │ ├── HexEncoder.cs │ │ ├── InformationRecord.cs │ │ ├── ModuleRecord.cs │ │ ├── ModuleStream.cs │ │ ├── ModuleUnit.cs │ │ ├── ModuleUnitType.cs │ │ ├── ModulesRecord.cs │ │ ├── ProjectPassword.cs │ │ ├── ProjectProtection.cs │ │ ├── ProjectProtectionState.cs │ │ ├── ProjectRecord.cs │ │ ├── ProjectVisibilityState.cs │ │ ├── ProjectWmRecord.cs │ │ ├── ReferenceProjectRecord.cs │ │ ├── ReferenceRecord.cs │ │ ├── ReferenceRecordType.cs │ │ ├── ReferenceRegisteredRecord.cs │ │ ├── ReferencesRecord.cs │ │ ├── StorageId.cs │ │ ├── StreamId.cs │ │ ├── SysKind.cs │ │ ├── VbaEncodings.cs │ │ ├── VbaEncryption.cs │ │ └── VbaProjectStream.cs │ ├── VbaCompiler.cs │ └── VbaCompiler.csproj └── vbamc │ ├── Icon.png │ ├── Program.cs │ ├── Properties │ └── launchSettings.json │ ├── README.md │ ├── data │ ├── MacroTemplate.dotx │ ├── MacroTemplate.potm │ └── MacroTemplate.xltx │ └── vbamc.csproj ├── tests ├── VbaCompiler.Benchmark │ ├── CompileMacroBenchmark.cs │ ├── CompileVbaProjectBenchmark.cs │ ├── Program.cs │ ├── VbaCompiler.Benchmark.csproj │ └── data │ │ ├── Class.vb │ │ ├── MacroTemplate.potm │ │ └── Module.vb └── VbaCompiler.Tests │ ├── GlobalUsings.cs │ ├── Streams │ └── VbaCompilerStreamsTests.cs │ ├── VbaCompiler.Tests.csproj │ ├── VbaEncryptionTests.cs │ ├── VbaSamplesNumberGenerator.cs │ └── data │ ├── Class.vb │ └── Module.vb ├── utils └── vbad │ ├── DirStream.cs │ ├── ModuleInfo.cs │ ├── Program.cs │ └── vbad.csproj └── vbamc.sln /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [Makefile] 4 | indent_size = 4 5 | indent_style = tab 6 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: ci 2 | 3 | on: 4 | push: 5 | pull_request: 6 | branches: main 7 | 8 | permissions: 9 | contents: read 10 | 11 | env: 12 | DOTNET_NOLOGO: 1 13 | DOTNET_CLI_TELEMETRY_OPTOUT: 1 14 | DOTNET_GENERATE_ASPNET_CERTIFICATE: 0 15 | RestoreLockedMode: true 16 | RepositoryBranch: '${{ github.ref_name }}' 17 | RepositoryCommit: '${{ github.sha }}' 18 | 19 | jobs: 20 | test: 21 | runs-on: ubuntu-22.04 22 | 23 | strategy: 24 | matrix: 25 | Configuration: ['Debug', 'Release'] 26 | 27 | env: 28 | Configuration: '${{ matrix.configuration }}' 29 | 30 | steps: 31 | - name: checkout 32 | uses: actions/checkout@v3 33 | with: 34 | submodules: true 35 | 36 | - name: setup dotnet 37 | uses: actions/setup-dotnet@v3 38 | with: 39 | dotnet-version: 8 40 | 41 | - name: restore 42 | run: dotnet restore 43 | 44 | - name: build 45 | run: dotnet build --no-restore 46 | 47 | - name: test 48 | run: dotnet test --no-restore --no-build 49 | 50 | - name: pack 51 | if: ${{ matrix.configuration == 'Release' }} 52 | run: | 53 | dotnet pack src/VbaCompiler/VbaCompiler.csproj --no-build --no-restore -o dist 54 | dotnet pack src/vbamc/vbamc.csproj --no-build --no-restore -o dist 55 | 56 | - name: publish artifact 57 | if: ${{ matrix.configuration == 'Release' }} 58 | uses: actions/upload-artifact@v3 59 | with: 60 | name: 'vbamc_packages_${{ matrix.configuration }}' 61 | path: '${{ github.workspace }}/dist' 62 | 63 | benchmark: 64 | runs-on: ${{ matrix.os }} 65 | 66 | strategy: 67 | matrix: 68 | os: ['ubuntu-22.04', 'windows-2022'] 69 | 70 | env: 71 | Configuration: 'Release' 72 | PROJECT: 'tests/VbaCompiler.Benchmark/VbaCompiler.Benchmark.csproj' 73 | 74 | steps: 75 | - name: checkout 76 | uses: actions/checkout@v3 77 | with: 78 | submodules: true 79 | 80 | - name: setup dotnet 81 | uses: actions/setup-dotnet@v3 82 | with: 83 | dotnet-version: 8 84 | 85 | - name: restore 86 | run: dotnet restore 87 | 88 | - name: build 89 | run: dotnet build --no-restore -c Release tests/VbaCompiler.Benchmark/VbaCompiler.Benchmark.csproj 90 | 91 | - name: benchmark 92 | shell: bash 93 | run: | 94 | dotnet run -c Release --project tests/VbaCompiler.Benchmark/VbaCompiler.Benchmark.csproj -- -e github --artifacts 95 | 96 | { 97 | echo "## VBA Compiler Benchmark" 98 | echo "" 99 | echo "Runner: \`${{ matrix.os }}\`" 100 | echo "" 101 | cat "BenchmarkDotNet.Artifacts/results/CompileMacroBenchmark-report-github.md" 102 | } >> $GITHUB_STEP_SUMMARY 103 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: release 2 | 3 | on: 4 | push: 5 | tags: [ 'v*.*.*' ] 6 | 7 | permissions: 8 | contents: read 9 | 10 | env: 11 | DOTNET_NOLOGO: 1 12 | DOTNET_CLI_TELEMETRY_OPTOUT: 1 13 | DOTNET_GENERATE_ASPNET_CERTIFICATE: 0 14 | RestoreLockedMode: true 15 | Configuration: Release 16 | RepositoryBranch: '${{ github.ref_name }}' 17 | RepositoryCommit: '${{ github.sha }}' 18 | 19 | jobs: 20 | build: 21 | 22 | runs-on: windows-2022 23 | 24 | steps: 25 | - name: checkout 26 | uses: actions/checkout@v3 27 | with: 28 | submodules: true 29 | 30 | - name: setup dotnet 31 | uses: actions/setup-dotnet@v3 32 | with: 33 | dotnet-version: 7 34 | 35 | - name: setup AzureSignTool 36 | if: steps.cache-dotnettools.outputs.cache-hit != 'true' 37 | run: dotnet tool install --verbosity minimal --global azuresigntool --version 4.0.1 38 | 39 | - name: setup NuGetKeyVaultSignTool 40 | if: steps.cache-dotnettools.outputs.cache-hit != 'true' 41 | run: dotnet tool install --verbosity minimal --global NuGetKeyVaultSignTool --version 3.2.2 42 | 43 | - name: restore 44 | run: dotnet restore 45 | 46 | - name: build 47 | run: dotnet build --no-restore 48 | 49 | - name: test 50 | run: dotnet test --no-restore --no-build 51 | 52 | - name: sign libraries 53 | id: sign_library 54 | if: ${{ success() && github.event_name == 'push' }} 55 | working-directory: '${{ github.workspace}}' 56 | run: | 57 | AzureSignTool.exe sign ` 58 | --file-digest sha256 ` 59 | --description-url "https://github.com/NetOfficeFw/vbamc" ` 60 | --no-page-hashing ` 61 | --timestamp-rfc3161 http://timestamp.digicert.com ` 62 | --timestamp-digest sha256 ` 63 | --azure-key-vault-url "${{ secrets.KEYVAULT_URL }}" ` 64 | --azure-key-vault-tenant-id "${{ secrets.KEYVAULT_TENANT_ID }}" ` 65 | --azure-key-vault-client-id "${{ secrets.KEYVAULT_CLIENT_ID }}" ` 66 | --azure-key-vault-client-secret "${{ secrets.AZURESIGNTOOL_CLIENT_SECRET }}" ` 67 | --azure-key-vault-certificate "goITSolutions-until-2024-01" ` 68 | --verbose ` 69 | src/VbaCompiler/bin/Release/net6.0/VbaCompiler.dll ` 70 | src/VbaCompiler/bin/Release/net7.0/VbaCompiler.dll ` 71 | src/vbamc/obj/Release/net6.0/vbamc.dll ` 72 | src/vbamc/obj/Release/net7.0/vbamc.dll 73 | 74 | - name: pack 75 | if: ${{ always() }} 76 | run: | 77 | dotnet pack src/VbaCompiler/VbaCompiler.csproj --no-build --no-restore -o dist 78 | dotnet pack src/vbamc/vbamc.csproj --no-build --no-restore -o dist 79 | 80 | - name: sign packages 81 | id: sign_package 82 | if: ${{ steps.sign_library.outcome == 'success' }} 83 | working-directory: '${{ github.workspace}}/dist' 84 | run: | 85 | NuGetKeyVaultSignTool.exe sign *.nupkg ` 86 | --file-digest sha256 ` 87 | --timestamp-rfc3161 http://timestamp.digicert.com ` 88 | --timestamp-digest sha256 ` 89 | --azure-key-vault-url "${{ secrets.KEYVAULT_URL }}" ` 90 | --azure-key-vault-tenant-id "${{ secrets.KEYVAULT_TENANT_ID }}" ` 91 | --azure-key-vault-client-id "${{ secrets.KEYVAULT_CLIENT_ID }}" ` 92 | --azure-key-vault-client-secret "${{ secrets.AZURESIGNTOOL_CLIENT_SECRET }}" ` 93 | --azure-key-vault-certificate "goITSolutions-until-2024-01" 94 | 95 | - name: publish packages 96 | if: ${{ steps.sign_package.outcome == 'success' }} 97 | working-directory: '${{ github.workspace}}/dist' 98 | run: | 99 | dotnet nuget push "*.nupkg" --api-key $env:NUGET_PUSH_KEY --source https://api.nuget.org/v3/index.json 100 | env: 101 | NUGET_PUSH_KEY: ${{ secrets.NUGET_PUSH_KEY }} 102 | 103 | - name: publish artifact 104 | uses: actions/upload-artifact@v3 105 | with: 106 | name: vbamc_build_${{ github.run_id }}_preview${{ github.run_number }} 107 | path: '${{ github.workspace }}/dist' 108 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ### DotnetCore ### 2 | # .NET Core build folders 3 | bin/ 4 | obj/ 5 | dist/ 6 | 7 | # Common node modules locations 8 | /node_modules 9 | /wwwroot/node_modules 10 | 11 | ### VisualStudioCode ### 12 | .vscode/* 13 | !.vscode/settings.json 14 | !.vscode/tasks.json 15 | !.vscode/launch.json 16 | !.vscode/extensions.json 17 | !.vscode/*.code-snippets 18 | 19 | # Local History for Visual Studio Code 20 | .history/ 21 | 22 | # Built Visual Studio Code Extensions 23 | *.vsix 24 | 25 | ### VisualStudioCode Patch ### 26 | # Ignore all local history of files 27 | .history 28 | .ionide 29 | 30 | # Support for Project snippet scope 31 | 32 | ### VisualStudio ### 33 | ## Ignore Visual Studio temporary files, build results, and 34 | ## files generated by popular Visual Studio add-ons. 35 | ## 36 | ## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore 37 | 38 | # User-specific files 39 | *.rsuser 40 | *.suo 41 | *.user 42 | *.userosscache 43 | *.sln.docstates 44 | 45 | # User-specific files (MonoDevelop/Xamarin Studio) 46 | *.userprefs 47 | 48 | # Mono auto generated files 49 | mono_crash.* 50 | 51 | # Build results 52 | [Dd]ebug/ 53 | [Dd]ebugPublic/ 54 | [Rr]elease/ 55 | [Rr]eleases/ 56 | x64/ 57 | x86/ 58 | [Ww][Ii][Nn]32/ 59 | [Aa][Rr][Mm]/ 60 | [Aa][Rr][Mm]64/ 61 | bld/ 62 | [Bb]in/ 63 | [Oo]bj/ 64 | [Ll]og/ 65 | [Ll]ogs/ 66 | 67 | # Visual Studio 2015/2017 cache/options directory 68 | .vs/ 69 | # Uncomment if you have tasks that create the project's static files in wwwroot 70 | #wwwroot/ 71 | 72 | # Visual Studio 2017 auto generated files 73 | Generated\ Files/ 74 | 75 | # MSTest test Results 76 | [Tt]est[Rr]esult*/ 77 | [Bb]uild[Ll]og.* 78 | 79 | # NUnit 80 | *.VisualState.xml 81 | TestResult.xml 82 | nunit-*.xml 83 | 84 | # Build Results of an ATL Project 85 | [Dd]ebugPS/ 86 | [Rr]eleasePS/ 87 | dlldata.c 88 | 89 | # Benchmark Results 90 | BenchmarkDotNet.Artifacts/ 91 | 92 | # .NET Core 93 | project.lock.json 94 | project.fragment.lock.json 95 | artifacts/ 96 | 97 | # ASP.NET Scaffolding 98 | ScaffoldingReadMe.txt 99 | 100 | # StyleCop 101 | StyleCopReport.xml 102 | 103 | # Files built by Visual Studio 104 | *_i.c 105 | *_p.c 106 | *_h.h 107 | *.ilk 108 | *.meta 109 | *.obj 110 | *.iobj 111 | *.pch 112 | *.pdb 113 | *.ipdb 114 | *.pgc 115 | *.pgd 116 | *.rsp 117 | *.sbr 118 | *.tlb 119 | *.tli 120 | *.tlh 121 | *.tmp 122 | *.tmp_proj 123 | *_wpftmp.csproj 124 | *.log 125 | *.tlog 126 | *.vspscc 127 | *.vssscc 128 | .builds 129 | *.pidb 130 | *.svclog 131 | *.scc 132 | 133 | # Chutzpah Test files 134 | _Chutzpah* 135 | 136 | # Visual C++ cache files 137 | ipch/ 138 | *.aps 139 | *.ncb 140 | *.opendb 141 | *.opensdf 142 | *.sdf 143 | *.cachefile 144 | *.VC.db 145 | *.VC.VC.opendb 146 | 147 | # Visual Studio profiler 148 | *.psess 149 | *.vsp 150 | *.vspx 151 | *.sap 152 | 153 | # Visual Studio Trace Files 154 | *.e2e 155 | 156 | # TFS 2012 Local Workspace 157 | $tf/ 158 | 159 | # Guidance Automation Toolkit 160 | *.gpState 161 | 162 | # ReSharper is a .NET coding add-in 163 | _ReSharper*/ 164 | *.[Rr]e[Ss]harper 165 | *.DotSettings.user 166 | 167 | # TeamCity is a build add-in 168 | _TeamCity* 169 | 170 | # DotCover is a Code Coverage Tool 171 | *.dotCover 172 | 173 | # AxoCover is a Code Coverage Tool 174 | .axoCover/* 175 | !.axoCover/settings.json 176 | 177 | # Coverlet is a free, cross platform Code Coverage Tool 178 | coverage*.json 179 | coverage*.xml 180 | coverage*.info 181 | 182 | # Visual Studio code coverage results 183 | *.coverage 184 | *.coveragexml 185 | 186 | # NCrunch 187 | _NCrunch_* 188 | .*crunch*.local.xml 189 | nCrunchTemp_* 190 | 191 | # MightyMoose 192 | *.mm.* 193 | AutoTest.Net/ 194 | 195 | # Web workbench (sass) 196 | .sass-cache/ 197 | 198 | # Installshield output folder 199 | [Ee]xpress/ 200 | 201 | # DocProject is a documentation generator add-in 202 | DocProject/buildhelp/ 203 | DocProject/Help/*.HxT 204 | DocProject/Help/*.HxC 205 | DocProject/Help/*.hhc 206 | DocProject/Help/*.hhk 207 | DocProject/Help/*.hhp 208 | DocProject/Help/Html2 209 | DocProject/Help/html 210 | 211 | # Click-Once directory 212 | publish/ 213 | 214 | # Publish Web Output 215 | *.[Pp]ublish.xml 216 | *.azurePubxml 217 | # Note: Comment the next line if you want to checkin your web deploy settings, 218 | # but database connection strings (with potential passwords) will be unencrypted 219 | *.pubxml 220 | *.publishproj 221 | 222 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 223 | # checkin your Azure Web App publish settings, but sensitive information contained 224 | # in these scripts will be unencrypted 225 | PublishScripts/ 226 | 227 | # NuGet Packages 228 | *.nupkg 229 | # NuGet Symbol Packages 230 | *.snupkg 231 | # The packages folder can be ignored because of Package Restore 232 | **/[Pp]ackages/* 233 | # except build/, which is used as an MSBuild target. 234 | !**/[Pp]ackages/build/ 235 | # Uncomment if necessary however generally it will be regenerated when needed 236 | #!**/[Pp]ackages/repositories.config 237 | # NuGet v3's project.json files produces more ignorable files 238 | *.nuget.props 239 | *.nuget.targets 240 | 241 | # Microsoft Azure Build Output 242 | csx/ 243 | *.build.csdef 244 | 245 | # Microsoft Azure Emulator 246 | ecf/ 247 | rcf/ 248 | 249 | # Windows Store app package directories and files 250 | AppPackages/ 251 | BundleArtifacts/ 252 | Package.StoreAssociation.xml 253 | _pkginfo.txt 254 | *.appx 255 | *.appxbundle 256 | *.appxupload 257 | 258 | # Visual Studio cache files 259 | # files ending in .cache can be ignored 260 | *.[Cc]ache 261 | # but keep track of directories ending in .cache 262 | !?*.[Cc]ache/ 263 | 264 | # Others 265 | ClientBin/ 266 | ~$* 267 | *~ 268 | *.dbmdl 269 | *.dbproj.schemaview 270 | *.jfm 271 | *.pfx 272 | *.publishsettings 273 | orleans.codegen.cs 274 | 275 | # Including strong name files can present a security risk 276 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 277 | #*.snk 278 | 279 | # Since there are multiple workflows, uncomment next line to ignore bower_components 280 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 281 | #bower_components/ 282 | 283 | # RIA/Silverlight projects 284 | Generated_Code/ 285 | 286 | # Backup & report files from converting an old project file 287 | # to a newer Visual Studio version. Backup files are not needed, 288 | # because we have git ;-) 289 | _UpgradeReport_Files/ 290 | Backup*/ 291 | UpgradeLog*.XML 292 | UpgradeLog*.htm 293 | ServiceFabricBackup/ 294 | *.rptproj.bak 295 | 296 | # SQL Server files 297 | *.mdf 298 | *.ldf 299 | *.ndf 300 | 301 | # Business Intelligence projects 302 | *.rdl.data 303 | *.bim.layout 304 | *.bim_*.settings 305 | *.rptproj.rsuser 306 | *- [Bb]ackup.rdl 307 | *- [Bb]ackup ([0-9]).rdl 308 | *- [Bb]ackup ([0-9][0-9]).rdl 309 | 310 | # Microsoft Fakes 311 | FakesAssemblies/ 312 | 313 | # GhostDoc plugin setting file 314 | *.GhostDoc.xml 315 | 316 | # Node.js Tools for Visual Studio 317 | .ntvs_analysis.dat 318 | node_modules/ 319 | 320 | # Visual Studio 6 build log 321 | *.plg 322 | 323 | # Visual Studio 6 workspace options file 324 | *.opt 325 | 326 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 327 | *.vbw 328 | 329 | # Visual Studio 6 auto-generated project file (contains which files were open etc.) 330 | *.vbp 331 | 332 | # Visual Studio 6 workspace and project file (working project files containing files to include in project) 333 | *.dsw 334 | *.dsp 335 | 336 | # Visual Studio 6 technical files 337 | 338 | # Visual Studio LightSwitch build output 339 | **/*.HTMLClient/GeneratedArtifacts 340 | **/*.DesktopClient/GeneratedArtifacts 341 | **/*.DesktopClient/ModelManifest.xml 342 | **/*.Server/GeneratedArtifacts 343 | **/*.Server/ModelManifest.xml 344 | _Pvt_Extensions 345 | 346 | # Paket dependency manager 347 | .paket/paket.exe 348 | paket-files/ 349 | 350 | # FAKE - F# Make 351 | .fake/ 352 | 353 | # CodeRush personal settings 354 | .cr/personal 355 | 356 | # Python Tools for Visual Studio (PTVS) 357 | __pycache__/ 358 | *.pyc 359 | 360 | # Cake - Uncomment if you are using it 361 | # tools/** 362 | # !tools/packages.config 363 | 364 | # Tabs Studio 365 | *.tss 366 | 367 | # Telerik's JustMock configuration file 368 | *.jmconfig 369 | 370 | # BizTalk build output 371 | *.btp.cs 372 | *.btm.cs 373 | *.odx.cs 374 | *.xsd.cs 375 | 376 | # OpenCover UI analysis results 377 | OpenCover/ 378 | 379 | # Azure Stream Analytics local run output 380 | ASALocalRun/ 381 | 382 | # MSBuild Binary and Structured Log 383 | *.binlog 384 | 385 | # NVidia Nsight GPU debugger configuration file 386 | *.nvuser 387 | 388 | # MFractors (Xamarin productivity tool) working folder 389 | .mfractor/ 390 | 391 | # Local History for Visual Studio 392 | .localhistory/ 393 | 394 | # Visual Studio History (VSHistory) files 395 | .vshistory/ 396 | 397 | # BeatPulse healthcheck temp database 398 | healthchecksdb 399 | 400 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 401 | MigrationBackup/ 402 | 403 | # Ionide (cross platform F# VS Code tools) working folder 404 | .ionide/ 405 | 406 | # Fody - auto-generated XML schema 407 | FodyWeavers.xsd 408 | 409 | # VS Code files for those working on multiple tools 410 | *.code-workspace 411 | 412 | # Local History for Visual Studio Code 413 | 414 | # Windows Installer files from build outputs 415 | *.cab 416 | *.msi 417 | *.msix 418 | *.msm 419 | *.msp 420 | 421 | ### macOS ### 422 | # General 423 | .DS_Store 424 | .AppleDouble 425 | .LSOverride 426 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "lib/VbaCompression"] 2 | path = lib/VbaCompression 3 | url = https://github.com/NetOfficeFw/VbaCompression 4 | -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "build", 6 | "command": "dotnet", 7 | "type": "process", 8 | "args": [ 9 | "build", 10 | "${workspaceFolder}/src/vbamc/vbamc.csproj", 11 | "/property:GenerateFullPaths=true", 12 | "/consoleloggerparameters:NoSummary" 13 | ], 14 | "problemMatcher": "$msCompile", 15 | "presentation": { 16 | "reveal": "silent", 17 | } 18 | }, 19 | { 20 | "label": "watch", 21 | "command": "dotnet", 22 | "type": "process", 23 | "args": [ 24 | "watch", 25 | "run", 26 | "--project", 27 | "${workspaceFolder}/src/vbamc/vbamc.csproj" 28 | ], 29 | "problemMatcher": "$msCompile" 30 | } 31 | ] 32 | } -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright © 2023 Jozef Izso 4 | © 2023 Cisco Systems, Inc. All rights reserved. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vbamc 2 | 3 | > Compile macro enabled add-ins for Microsoft Office applications. 4 | 5 | Compiler `vbamc` compiles Visual Basic source code and Ribbon customizations to Microsoft Office macro files or macro enabled add-ins. It supports Microsoft Word, Excel and PowerPoint. 6 | 7 | 8 | ## Installation 9 | 10 | Use `dotnet tool` command to install the `vbamc` compiler: 11 | 12 | ```commandline 13 | dotnet tool install --global vbamc 14 | ``` 15 | 16 | 17 | ## Usage 18 | 19 | Pass the list of source code files with modules and classes to the compiler: 20 | 21 | ```commandline 22 | vbamc -m Module.vb -c MyClass.vb -f AcmeSample.ppam -n "Sample Addin" --company "ACME" 23 | ``` 24 | 25 | It will generate the PowerPoint Add-in macro file named `AcmeSampleMacro.ppam` usable 26 | in Microsoft PowerPoint. 27 | 28 | 29 | ## When to use macros and why 30 | 31 | There are several principal reasons to consider using Visual Basic 32 | for Applications (VBA) macros in Microsoft Office. 33 | 34 | 35 | ### Automation and repetition 36 | 37 | VBA is effective and efficient when it comes to repetitive solutions to formatting or correction problems. For example, have you ever changed the style of the paragraph at the top of each page in Word? Have you ever had to reformat multiple tables that were pasted from Excel into a Word document or an Outlook email? Have you ever had to make the same change in multiple Outlook contacts? 38 | 39 | If you have a change that you have to make more than ten or twenty times, it may be worth automating it with VBA. If it is a change that you have to do hundreds of times, it certainly is worth considering. Almost any formatting or editing change that you can do by hand, can be done in VBA. 40 | 41 | ### Extensions to user interaction 42 | 43 | There are times when you want to encourage or compel users to interact with the Office application or document in a particular way that is not part of the standard application. For example, you might want to prompt users to take some particular action when they open, save, or print a document. 44 | 45 | ### Interaction between Office applications 46 | 47 | Do you need to copy all of your contacts from Outlook to Word and then format them in some particular way? Or, do you need to move data from Excel to a set of PowerPoint slides? Sometimes simple copy and paste does not do what you want it to do, or it is too slow. Use VBA programming to interact with the details of two or more Office applications at the same time and then modify the content in one application based on the content in another. 48 | 49 | ### Doing things another way 50 | 51 | VBA programming is a powerful solution, but it is not always the optimal approach. Sometimes it makes sense to use other ways to achieve your aims. 52 | 53 | The critical question to ask is whether there is an easier way. Before you begin a VBA project, consider the built-in tools and standard functionalities. For example, if you have a time-consuming editing or layout task, consider using styles or accelerator keys to solve the problem. Can you perform the task once and then use CTRL+Y (Redo) to repeat it? Can you create a new document with the correct format or template, and then copy the content into that new document? 54 | 55 | Office applications are powerful; the solution that you need may already be there. Take some time to learn more about Office before you jump into programming. 56 | 57 | Before you begin a VBA project, ensure that you have the time to work with VBA. Programming requires focus and can be unpredictable. Especially as a beginner, never turn to programming unless you have time to work carefully. Trying to write a "quick script" to solve a problem when a deadline looms can result in a very stressful situation. If you are in a rush, you might want to use conventional methods, even if they are monotonous and repetitive. 58 | 59 | 60 | > Source: [Getting started with VBA in Office](https://learn.microsoft.com/en-us/office/vba/library-reference/concepts/getting-started-with-vba-in-office), under [CC-BY-4.0](https://github.com/MicrosoftDocs/VBA-Docs/blob/main/LICENSE) license. 61 | 62 | 63 | ## License 64 | 65 | Source code is licensed under [MIT License](LICENSE.txt). 66 | 67 | Copyright © 2023 Jozef Izso 68 | © 2023 Cisco Systems, Inc. All rights reserved. 69 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | dotnet publish -c Release -r osx.10.15-x64 -f net6.0 --self-contained true -o dist 4 | -------------------------------------------------------------------------------- /sample/Class1.vb: -------------------------------------------------------------------------------- 1 | Public Sub MainMethod() 2 | ' call me maybe 3 | End Sub 4 | -------------------------------------------------------------------------------- /sample/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright 2022 Cisco Systems, Inc. 2 | # Licensed under MIT-style license (see LICENSE.txt file). 3 | 4 | framework := net7.0 5 | 6 | .PHONY: all 7 | all: addin 8 | 9 | .PHONY: addin 10 | addin: bin/PresentationAddin.ppam bin/PresentationAddin.pptm 11 | 12 | MODULES = Module1.vb 13 | CLASSES = Class1.vb 14 | 15 | bin/PresentationAddin.ppam: $(MODULES) $(CLASSES) 16 | ../src/vbamc/bin/Debug/$(framework)/vbamc -m $(MODULES) -c $(CLASSES) -f "PresentationAddin.ppam" -n "Sample Addin" --company "ACME" -p Generator=VbaCompiler 17 | 18 | bin/PresentationAddin.pptm: $(MODULES) $(CLASSES) 19 | ../src/vbamc/bin/Debug/$(framework)/vbamc -m $(MODULES) -c $(CLASSES) -f "PresentationAddin.pptm" -n "Sample Addin" --company "ACME" -p Generator=VbaCompiler 20 | 21 | .PHONY: clean 22 | clean: 23 | rm -rf bin/ obj/ 24 | -------------------------------------------------------------------------------- /sample/Module1.vb: -------------------------------------------------------------------------------- 1 | ' Module source code 2 | Declare PtrSafe Function GetCurrentProcessId Lib "kernel32" () As Long 3 | 4 | Public Sub Auto_Open() 5 | ' execute code when application starts 6 | ' MsgBox "Hello world from " & Application.Name & ", PID " & CStr(GetCurrentProcessId) 7 | End Sub 8 | 9 | Public Sub OnActionAbout(control As IRibbonControl) 10 | MsgBox "User profile: ~/" 11 | MsgBox "Hello world from " & Application.Name & ", PID " & CStr(GetCurrentProcessId) 12 | End Sub 13 | -------------------------------------------------------------------------------- /sample/ThisDocument.vb: -------------------------------------------------------------------------------- 1 | ' ThisDocument file 2 | 3 | Public Sub ShowMessage() 4 | MsgBox "Hello world from " & Application.Name & ", PID " & CStr(GetCurrentProcessId) 5 | End Sub 6 | -------------------------------------------------------------------------------- /sample/customUI/customUI14.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |