XVBA — Live Server VBA for Excel & Access
Edit VBA code in Visual Studio Code with IntelliSense, a smart Live Server, snippets, auto-complete, ribbon designer, and macro runner — all tightly integrated with Excel and Access.
What's New in 4.0.34
| Feature |
Description |
| Stable production package |
All fixes from 4.0.32 and 4.0.33 verified working in the packaged .vsix. The any-promise bundling fix, synchronous temp-file creation, and full activation logging are confirmed working after install. |
| CHANGELOG updated |
Versions 4.0.32 – 4.0.34 fully documented in CHANGELOG.md. |
What's New in 4.0.33
| Feature |
Description |
| Temp files created on every activation (build fix) |
VBScript and XML communication files are now reliably created at activation in both development and production builds. Root cause: any-promise was listed as a webpack external, causing a Cannot find module 'any-promise' crash that silently prevented the entire extension from loading when installed from the .vsix. Removed from externals so it is bundled correctly. |
| Synchronous file creation |
Folders and files are created with mkdirSync / writeFileSync (same pattern used by the logger) so there is no race condition between activation and the first command. |
| Full per-file logging |
Every folder and file operation logs [XVBA] dir OK/FAIL and [XVBA] file OK/FAIL with the exact path — makes diagnosing permission or path problems instant. |
What's New in 4.0.32
| Feature |
Description |
| VBScript from memory |
The extension no longer ships or reads .vbs files from its install folder. All VBScript communication files are generated from TypeScript resource strings and written to the OS temp folder on every activation. This means the VSIX is smaller, the scripts are always up-to-date, and there is no dependency on external files that a user or AV tool could accidentally delete or modify. |
| Reliable temp-folder creation |
createFolderIfNotExist now uses { recursive: true } so intermediate folders are always created in one call, even on a clean user profile. |
| Errors surfaced, not swallowed |
fileWrite, writeFileIfNotExist, and createConcatenatedScriptFile previously caught errors and returned false or called console.log, hiding the real failure. They now throw so the caller can log the exact problem. |
| Per-step activation logging |
Each VBScript file creation step logs its target path on success ([XVBA] VBScript Run Macro ready: …) and the full error on failure, making it easy to diagnose permission or path problems in the XVBA log. |
What's New in 4.0.31
| Feature |
Description |
| Export Changed VBA |
Sends only modified files to Excel. First run captures a baseline snapshot; every subsequent run compares file modification times and pushes only what actually changed. |
| Smart Live Server |
On every file save the watcher detects which single file changed and sends only that module (RUN_CHANGED). Duplicate OS events for the same save are silently discarded by an mtime guard. |
| No freeze on import |
ScreenUpdating, Calculation, and EnableEvents are disabled during VBA import. book.Save is no longer called automatically — saving inside VBScript was the primary cause of Excel freezing mid-import. |
| Import → sync |
After Import VBA pulls files from Excel into VSCode the change-tracker snapshot is refreshed, so the Live Server will not immediately send those files back. |
| Sheet / class fix |
.cls files that map to existing workbook components (sheets, ThisWorkbook, class modules) are updated in-place instead of removed and re-imported, preventing duplicate sheet tabs. |
| Dev (With Line Number) |
Line numbering is now accurate — every non-blank VBA line is prefixed with its 1-based source index. Erl() in Excel returns the exact VS Code line number where the error occurred. |
| No-folder stability |
Fixed a crash where opening VSCode without a workspace folder caused the LSP server to throw an unhandled exception and break the extension. |
| Fast startup |
Extension no longer blocks the activation sequence on disk I/O. VBScript communication files are written in the background, eliminating the "extension host did not start in 10 seconds" timeout. |
Key Features
- Edit VBA in VSCode — navigate, search, refactor, and version-control your VBA code with the full power of VS Code.
- Live Server — save a
.bas, .cls, or .frm file and it appears in Excel automatically. Only the changed file is sent.
- Export Changed VBA — manually push only modified files at any time without reloading the whole project.
- Import VBA — pull the current state of all VBA modules from Excel or Access into your workspace.
- Run Macros from TreeView — click any macro in the XVBA panel to run it in Excel with a full error log.
- Namespace / folder organisation — map VBA files to sub-folders using the
'namespace= tag.
- Auto-complete (LSP) — language server provides context-aware completions, hover docs, and go-to-definition.
- Syntax highlighting — full VBA/VBScript grammar including
.cls, .bas, .frm, .vbs, .catscript.
- Code formatter — auto-indent and format with
Alt+Shift+F (set formatter to local-smart.excel-live-server).
- Snippets — all XVBA snippets start with
x- (block comment, Dim declarations, Sub/Function, etc.).
- Custom Ribbon Menus — build Excel ribbon XML with custom images directly from VSCode.
- Immediate Window (Xdebug) — simulate VBA's Immediate Window inside the VSCode output channel.
- Production / Dev modes — files in
xvba_unit_test are exported only in Production mode.
- Third-party packages — install VBA packages via
@localsmart/xvba-cli and the xvba.dev registry.
- Type definition files —
.d.vb files for Excel object model auto-complete.
Installation
Save your work and make a backup before setting up the server for the first time.
1 — Allow Excel to run macros on open
2 — Bootstrap XVBA
Click the Bootstrap icon in the XVBA tree view. This creates config.json in your workspace root:
{
"app_name": "XVBA",
"excel_file": "index.xlsb",
"vba_folder": "vba-files"
}
vba_folder must be a path relative to the workspace no absolute paths.
3 — Import VBA (optional)
If your Excel file already contains VBA code, click Import VBA to pull all modules into your workspace.
4 — Start the Live Server
Click Start XVBA Live Server. From this point every file you save is automatically pushed to Excel only the changed file, instantly.
| Icon |
Command |
Description |
| Bootstrap |
Bootstrap XVBA Config |
Create / reconfigure config.json |
| Import |
Import - VBA |
Pull all VBA from Excel into VSCode. Stops the Live Server while running. |
| Stop |
Stop XVBA Live Server |
Stop the file watcher |
| Export VBA |
Export VBA |
Push all VBA files to Excel at once. Three modes: Development, Dev (With Line Number), Production. |
| Export Changed |
Export Changed VBA |
Push only files modified since the last export |
| Live Server |
Start XVBA Live Server |
Watch for file changes and auto-push to Excel |
| Ribbon |
Add Custom Ribbon Menu |
Generate / edit ribbon XML |
| Open Office |
Open MS Office |
Open the configured Excel / Access file |
| Refresh |
Refresh Macros |
Reload the macro list in the tree view |
Export Changed VBA — How it works
- First click — XVBA captures a snapshot of all VBA file modification times. Nothing is sent to Excel yet. A message confirms the baseline is ready.
- Edit any file and click again — only files whose mtime is newer than the snapshot are sent to Excel.
ScreenUpdating, Calculation, and EnableEvents are disabled during import so Excel does not freeze.
- After each successful export the snapshot is updated so only new changes are detected next time.
To reset the baseline manually, delete %TEMP%\xvba_change_tracker.json.
Live Server How it works
- Start — initialises the change-tracking snapshot and registers watchers on
vba_folder, xvba_modules, and xvba_unit_test.
- On save — chokidar fires a
change event with the exact file path. The mtime is compared against the snapshot. If genuinely newer, only that one file is sent via RUN_CHANGED. Duplicate OS events (Windows fires 2-3 per save) are discarded.
- After export — the snapshot entry for that file is updated (
markFilesAsExported).
- Import VBA — automatically stops the watcher and refreshes the snapshot when import finishes, so the Live Server will not re-send the newly imported files.
Namespace Organise VBA Files in Sub-folders
Add a 'namespace= tag at the top of any VBA file to control which folder it lives in:
'namespace=Controllers
Public Sub PageController()
' ...
End Sub
Run Macros from TreeView
Right-click any macro in the XVBA — Macro List panel and select Run Macro. Results and errors appear in excel_exec.log.
Function MyMacro()
On Error Resume Next
Err.Source = "MyMacro"
' your code here
End Function
Export Modes
When clicking Export VBA you are prompted for a mode:
| Mode |
Description |
| Development |
Imports your VBA files as-is into Excel. Use for normal development. |
| Dev (With Line Number) |
Adds VBA line-number labels to every executable line before importing. When a runtime error occurs, Erl() returns the exact line number matching your VS Code file. |
| Production |
Also imports files from xvba_unit_test into Excel. Use for releases. |
Using Erl() for error location
Sub MyMacro()
On Error GoTo ErrHandler
' ... your code ...
Exit Sub
ErrHandler:
MsgBox "Error at line " & Erl & " — " & Err.Description
End Sub
With Dev (With Line Number) active, Erl returns the same line number shown in VS Code, so you can navigate directly to the failing line.
Set the default formatter to local-smart.excel-live-server in VSCode settings and use Alt+Shift+F to format any VBA file.
Install the Xdebug package to simulate Excel's Immediate Window inside the VSCode output channel.
The first comment block in a file is used as the module/class description for hover and auto-complete:
'/*
'
' My module description
'
'*/
Public Sub Main()
End Sub
Code Annotations
| Annotation |
Effect |
@ignore-comment |
Hide this comment from completions/hover |
@module-comment |
Mark as the module description block (.bas, .frm) |
@class-comment |
Mark as the class description block (.cls) |
XVBA-CLI Package Manager
Install third-party VBA packages from xvba.dev:
npm i @localsmart/xvba-cli@latest --save-dev
See XVBA-CLI on npm.
Snippets
All XVBA snippets start with x-. Examples:
| Snippet |
Inserts |
x-blc |
Block comment |
x-ns |
Namespace tag |
x-dim |
Dim declaration |
x-sub |
Sub template |
x-fn |
Function template |
Troubleshooting
File encoding issues — VBA files use Windows-1252 encoding. Add to VSCode settings.json:
"files.encoding": "windows1252",
"files.autoGuessEncoding": true
Sheets disappear after import — Go to Excel View menu and select Unhide.
Trust access to VBA project — Excel must have Trust access to the VBA project object model enabled:
File -> Options -> Trust Center -> Macro Settings -> check the box.
Export Changed VBA always shows no changes — Delete %TEMP%\xvba_change_tracker.json to reset the snapshot.
Excel freezes after Live Server sends a file — Fixed in 4.0.31. If it still occurs, make sure you are running the latest built extension (npm run webpack) and reload the extension host.
Extension host did not start in 10 seconds — Fixed in 4.0.31. The extension now completes activation immediately and writes VBScript files in the background.
VBScript files not created in temp folder — Fixed in 4.0.33. The root cause was any-promise listed as a webpack external, causing a silent crash at extension load time. All .vbs and .xml communication files are now written synchronously on every activation. Check %TEMP%\xvba_log\xvba_info.log for [XVBA] dir OK / [XVBA] file OK entries confirming each path, or FAIL entries with the exact error.
Dev (With Line Number) imports wrong lines — Fixed in 4.0.31. Line numbers now map 1-to-1 with VS Code line indices so Erl() is accurate.
System Requirements
- Windows 10 / 11
- Microsoft Office 2016 or later (tested with Office 2019)
- Not tested on macOS or virtual machines
- Node.js 12+ (required for xvba-cli only)
YouTube Tutorials
XVBA YouTube Channel
- How to install — First Steps
- Namespace — Organise files in sub-folders
- Create Custom Ribbon Menus
- Use Production / Dev mode
- Code Formatter
- Git with VBA
- Comment blocks and type definition files
- Install xvba-cli and use packages
Support XVBA
If you find XVBA useful, please consider becoming a sponsor on Patreon to help build a free programming school in Vargem Bonita, Brazil and keep the tools improving.
Contributing
Contributions are welcomed and appreciated.
- GitHub: Aeraphe
- Mail: alberto.aeraph@gmail.com
- WhatsApp: +55 31 9 9229 5626
- Please leave a review and star the repo
Built With
Version History
See CHANGELOG.md.