📤 EXCEL VBA module Sync - VSCode ⇄ Excel

目次 / Contents
概要(Japanese)
EXCEL VBA module Sync は、開いているExcel の VBA モジュールを VSCode 上で編集するための拡張機能です。
VBA モジュールのVSCodeへのエクスポート、VSCodeで編集した内容のVBAへのインポートが行えます。
Winsdows10/11+Excel+VSCode環境でのみ動作します。
🤖 AIエージェント連携(MCP対応):Claude Code・Claude Desktop・VS Code内蔵のCopilot Chatなど、Model Context Protocol (MCP)に対応したAIクライアントから、VBAコードの読み取り・検索・マクロ実行に加えてコードの書き込みまでを行えます。書き込みはdryRun→confirmTokenの2段階確認フロー・書き込み前の自動バックアップ・複数クライアント同時利用時の楽観的排他制御を備えた設計です。詳細は🤖 AIクライアントから使うを参照。
- ✅ 開いているExcelブックから
.bas / .cls / .frm 内のコードをエクスポート(保存)
- ✅ VSCode 上で編集
- ✅ 編集したモジュールを 開いているExcelブック にインポート(反映)
- ✅ インポートはモジュール差し替えにて行います
- ✅ エクスポートしたモジュールファイルはgitで管理しやすいようにUTF-8の文字コードで出力されます。
- ✅ Excel マクロ実行(モジュール+プロシージャ、または完全修飾名で実行可能)
- ✅ VBA コード検索(開いている全ブック・全モジュールを対象に、正規表現やフィルタ指定で検索可能)
- ✅ フローチャート作成(右クリックで選択したモジュールのフローチャートを作成)
🔧 主な機能
- Export All Modules From VBA — 開いているExcel から全モジュールを抽出・保存
- Import Module To VBA — VSCode 上で編集したコードを Excel に反映(単独モジュール/ファイル)
- Set Export Folder — エクスポート先フォルダをダイアログにて選択
- Excel VBA: List & Run Macro — 開いているブックより指定マクロを実行
- Excel VBA: Search VBA Code — 開いているブック・モジュール対象にコード検索(正規表現対応)
- Generate VBA Flow Chart(実験的機能) — エクスポート先フォルダに mmdフォルダを作成し、マーメイド形式(*.mmd)で簡易フローチャートを出力
- Excel VBA: Print MCP Server Config (for AI) — AIクライアント(Claude Code/Desktop等)向けのMCP接続設定を生成
- コマンドパレット/ボタン対応 — GUI 操作または
Ctrl+Shift+P から実行可
Overview (English)
EXCEL VBA module Sync is a VSCode extension for editing opened Excel VBA modules.
You can export VBA modules to VS Code and import the content edited in VS Code back into VBA.
Works in a Windows 10/11 + Excel + VS Code environment only.
🤖 AI agent integration (MCP): From any Model Context Protocol (MCP) client — Claude Code, Claude Desktop, or VS Code's own Copilot Chat — read, search, run macros in, and write VBA code. Writes go through a two-step dryRun/confirmToken confirmation flow, an automatic backup before every change, and optimistic concurrency control when multiple clients are active. See 🤖 Use from an AI client for details.
- ✅ Export inner code of
.bas / .cls / .frm from opened Excel
- ✅ Edit VBA modules in VSCode
- ✅ Import modules back into opened Excel
- ✅ Import is performed by replacing the module.
- ✅ Exported module files are saved in UTF-8 encoding, making them easier to manage with Git.
- ✅ Execute Excel macros (by module/procedure or fully qualified name)
- ✅ Search VBA code (across all open workbooks/modules, with regex and filters supported)
- ✅ Generate flowchart (Create a flowchart for the module selected with right-click)
🔧 Features
- Export All Modules From VBA — Extract and save all VBA modules from opened Excel
- Import Module To VBA — Reflect modified code back to opened Excel (module-based/file-based)
- Set Export Folder — Change export folder via dialog
- Excel VBA: List & Run Macro — Execute macros by name or fully qualified path in the open workbook
- Excel VBA: Search VBA Code — Search VBA code in the open workbook (with regex support)
- Generate VBA Flow Chart (Experimental) — Create an mmd folder in the export destination and output a simple flowchart in Mermaid format (*.mmd)
- Excel VBA: Print MCP Server Config (for AI) — Generate an MCP connection config for AI clients (Claude Code/Desktop, etc.)
- Command Palette / GUI support — Use commands or side panel buttons
🧩 インストール(VSIX) / Install from VSIX
From Marketplace
- Visual Studio Marketplace - excel-vba-sync
- Visual Studio Code を開き、拡張機能ビューからインストール
拡張機能ビューからできない場合は、以下をお試しください。
From Marketplace(Powershell)
以下コマンドを実行
code --install-extension 9kv8xiyi.excel-vba-sync
From Github(VSCode)
- https://github.com/EitaroSeta/excel-vba-sync/releases/download/latest/extension.vsix より
extension.vsixをダウンロード
- VS Code を開く
- 拡張機能ビュー(Ctrl+Shift+X / Cmd+Shift+X)を開く
- 右上の「…」メニュー → VSIXからのインストール... を選択
- ダウンロードした
extension.vsix ファイルを選択
- Reloadを実行
From Github(Powershell)
以下コマンドを実行
$URL = "https://github.com/EitaroSeta/excel-vba-sync/releases/download/latest/extension.vsix"
$OUT = "$env:TEMP\extension.vsix"
curl.exe -sS -L -f --retry 3 --retry-delay 2 "$URL" -o "$OUT"
code --install-extension "$OUT"
🤖 AIクライアントから使う(Claude Code / Claude Desktop) / Use from an AI client
この拡張機能にはModel Context Protocol (MCP)サーバーが内蔵されており、Claude Code・Claude Desktopなどの外部AIクライアントから、VBAコードの読み取り・検索・マクロ実行に加えて、AIが書いたコードをExcelのVBAモジュールへ直接書き込むことができます。
セットアップ手順・安全設計・既知の注意点は docs/AI_USAGE.md を参照してください。
This extension has a built-in Model Context Protocol (MCP) server, allowing external AI clients such as Claude Code and Claude Desktop to read, search, and run VBA code — and even write AI-authored code directly into an Excel VBA module.
See docs/AI_USAGE.md for setup steps, safety design, and known caveats.
⚠重要 / Important
[!WARNING]
EXCELファイルは必ずバックアップしてください。
この拡張機能はCOM経由でExcelファイルを外部から操作するため、条件によりファイルを破損させる恐れがあります。特に、AIエージェントがMCP経由で自動的にコードの読み書き・マクロ実行を行う運用では、人が都度確認する場合に比べて意図しない上書き・実行が起きるリスクが通常の利用より高くなります。作業前に必ずバックアップを取得してください。
Always back up your Excel files before use. This extension operates on Excel files externally via COM, so there is a risk of file corruption depending on conditions. This risk is higher than normal when an AI agent is driving the tools autonomously via MCP (automatic code read/write and macro execution), since there is no per-step human confirmation. Always back up your files before starting.
●エクスポートしたファイルの属性は編集しないでください
エクスポートした .frm/.cls/.bas の 属性行は編集しないでください。VERSION、Begin … End、Object = …、および Attribute VB_*(例:VB_Name / VB_PredeclaredId / VB_Exposed / VB_Creatable など)を変更すると、インポート失敗や既存フォームとの紐付け崩れが発生します。
●モジュールの新規追加はできません
既存のモジュール/クラス/フォームを入替えを行う仕組みの為、新規の追加はできません。 VBA上で新規モジュールを追加し、エクスポートしてください。
●COMエラーについて
Excel に長時間触れずに放置した後や、画面ロック復帰直後などにインポート/エクスポートを実行すると、
次のようなエラーが発生する場合があります。
STDERR: Call was rejected by callee. (HRESULT からの例外:0x80010001 (RPC_E_CALL_REJECTED))
これは Excel 側が一時的に応答できない状態にあるため、COM 呼び出しが失敗して発生するエラーです。
この場合は Excelを再起動すると解消されます。
●Do not edit attributes of exported files
Do not edit the attribute lines in exported .frm/.cls/.bas files. Changing VERSION, Begin … End, Object = …, or any Attribute VB_* (e.g., VB_Name, VB_PredeclaredId, VB_Exposed, VB_Creatable) can cause import failures, and loss of linkage to the original form.
●New modules, classes, or forms cannot be added;
New modules, classes, or forms cannot be added; this tool only replaces existing ones.If you need to create a new item, first add a blank module/class/form in the VBE, then export it.
●About COM Error
When running import/export operations after leaving Excel idle for a long time or resuming from a screen lock,
you may encounter the following error:
STDERR: Call was rejected by callee. (HRESULT 0x80010001)
This occurs because Excel is temporarily unable to respond, causing the COM call to fail.
Restarting Excel will resolve the issue.
免責事項 / Disclaimer
本拡張機能は現状有姿(as-is)で提供されます。MCPサーバー経由でAIエージェントが行った操作を含め、本拡張機能の使用によって生じたExcelファイルの破損・データ損失・その他いかなる損害についても、作者は一切の責任を負いません。自己責任でご利用の上、必ず事前にバックアップを取得してください。
This extension is provided "as is", without warranty of any kind. The author accepts no liability for any damage — including but not limited to file corruption or data loss — resulting from use of this extension, including actions taken by an AI agent via the MCP server. Use at your own risk, and always back up your Excel files beforehand.
🛠 開発者向け情報 / Development (for GitHub users)
このセクションは拡張機能の利用者には不要です。拡張の開発や修正、ローカライズ設定、アーキテクチャ図は docs/DEVELOPMENT.md を参照してください。
This section is unnecessary for extension users. See docs/DEVELOPMENT.md for build/dev setup, packaging, localization, and the architecture diagram.
開発体制について: v0.0.28以降の実装は、Claude(Anthropic)とのAI協働(vibe coding)によって行われています。詳細はdocs/DEVELOPMENT.mdを参照してください。
About the development process: Since v0.0.28, implementation has been done via AI-assisted development ("vibe coding") with Claude (Anthropic). See docs/DEVELOPMENT.md for details.
https://github.com/EitaroSeta/excel-vba-sync