ENGLISH | 日本語
Excel VBA Extension EN
A VS Code extension for developing Excel VBA / Sheets / CustomUI.
Key Benefits:
- Editing in VS Code
- Edit, add, update, and delete VBA files
- Edit, add, update, and delete Excel Sheets
- Edit and update CustomUI XML files
- Execute Sub procedures of VBA files from VS Code
- Integration with VS Code
- Version control for VBA files, Excel sheets, and CustomUI XML files
- Apply generative AI to VBA files, Excel sheets, and CustomUI XML files

Features
| Feature |
Description |
| Open Excel Book |
Open Excel files from Explorer View. |
| Load VBA from Excel Book |
Extract VBA files (.bas, .cls, .frm) from book files (.xlsm, .xlam). |
| Save VBA to Excel Book |
Save VBA files edited in VS Code to book files. |
| Compare VBA with Excel Book |
Compare code edited in VS Code with the state of book files. |
| Run VBA Sub at Cursor |
Execute the Sub procedure at cursor position in Excel. |
| Load Sheets from Excel Book |
Export sheets (.csv) from book files as CSV files. |
| Save Sheets to Excel Book |
Save CSV files edited in VS Code to book file sheets. |
| Load CustomUI from Excel Book |
Export CustomUI (customUI.xml, customUI14.xml) from book files. |
| Save CustomUI to Excel Book |
Save CustomUI edited in VS Code to book files. |
Setup
Macro Security Settings
Configure settings to allow the extension to access Excel VBA.
- Open Excel
- Select File → Options → Trust Center
- Click Trust Center Settings
- In the Macro Settings section, verify:
- Check Trust access to the VBA project object model
- Click OK to save settings
Usage
Right-click a book file in Explorer View or click the icon in the editor title to run commands.
Open Excel File
- Select a book file in Explorer View
- Select Open Excel Book from the editor title
- File opens in Excel
Load VBA
- Open the book file in Excel
- Select the book file in VS Code's Explorer View
- Select Load VBA from Excel Book from the editor title
- A folder with the same name as the book file is created
- Example:
MyBook.xlsm → MyBook_xlsm folder
Edit VBA
Edit VBA files in VS Code.
Compare VBA
- Select the book file in Explorer View
- Select Compare VBA with Excel Book from the editor title
- Differences with the book file are displayed
Save VBA
- Select the book file in Explorer View
- Select Save VBA to Excel Book from the editor title
- Changes are saved to the book file
- For .xlam files, you cannot save directly from the extension. Save from the VB Editor toolbar.
Run Sub Procedure
- Open the VBA file in the editor
- Place the cursor inside the Sub procedure you want to run
- Select Run VBA Sub at Cursor from the editor title
- The following processes are executed automatically:
- Save changes to the book file
- Execute the Sub procedure in Excel
Load CustomUI
- Select the book file in Explorer View
- Select Load CustomUI from Excel Book from the editor title
- A folder with the same name as the book file is created
- Example:
MyAddin.xlam → MyAddin_customUI folder
- CustomUI XML files (customUI.xml, customUI14.xml) are extracted directly into the folder
Edit CustomUI
Edit CustomUI XML files (customUI.xml, customUI14.xml) in VS Code.
Save CustomUI
- Select the book file in Explorer View
- Select Save CustomUI to Excel Book from the editor title
- Changes are saved to the book file's CustomUI
Notes
- General
- Files downloaded from the internet require unblocking access.
- Manage book files with a version control system in case they become corrupted.
- Add-in Files
- For .xlam files, they cannot be saved directly from the extension. Please save from the VB Editor toolbar.
- VBA Files
- VBA files use Shift_JIS character encoding.
- .frx corresponding to .frm is automatically generated. If you delete .frx, .frm cannot be saved.
- CSV Files
- Sheets with ".csv" in the name are treated as targets for processing.
- Additional
- VBA files can be created new in VS Code.
- CSV files can be created new in VS Code.
- CustomUI XML files cannot be created new. They must be registered in the book file beforehand.
Excel VBA Extension JP
VS Code で Excel VBA を開発するための拡張機能です。
主な利点:
- VS Codeでの編集
- VBA ファイルの編集、追加・更新・削除
- Excel シートの編集、追加・更新・削除
- CustomUI XML ファイルの編集、更新
- VBA ファイルの Sub プロシージャの VS Code からの実行
- VS Codeとの統合
- VBA ファイル、Excelシート、CustomUI XMLファイルのバージョン管理
- VBA ファイル、Excelシート、CustomUI XMLファイルへの生成AIの適用

機能
| 機能 |
説明 |
| Open Excel Book |
エクスプローラービューから Excel ファイルを開く。 |
| Load VBA from Excel Book |
ブックファイル(.xlsm, .xlam)から VBA ファイル(.bas, .cls, .frm)を読み込む。 |
| Save VBA to Excel Book |
VS Code で編集した VBA ファイルをブックファイルに保存する。 |
| Compare VBA with Excel Book |
VS Code で編集したコードとブックファイルの状態を比較する。 |
| Run VBA Sub at Cursor |
カーソル位置の Sub プロシージャを Excel で実行する。 |
| Load Sheets from Excel Book |
ブックファイルのシート(.csv)を CSV ファイルに保存する。 |
| Save Sheets to Excel Book |
VS Code で編集した CSV ファイルをブックファイルに保存する。 |
| Load CustomUI from Excel Book |
ブックファイルから CustomUI(customUI.xml, customUI14.xml)をエクスポートする。 |
| Save CustomUI to Excel Book |
VS Code で編集した CustomUI をブックファイルに保存する。 |
準備
マクロセキュリティ設定
拡張機能が Excel VBA にアクセスするための設定をします。
- Excel を開く
- ファイル → オプション → セキュリティセンター(トラストセンター) を選択
- セキュリティセンターの設定(トラストセンターの設定) をクリック
- マクロのセキュリティ セクションで以下を確認:
- VBA プロジェクトオブジェクトモデルへのアクセスを信頼する にチェックを入れる
- OK をクリックして設定を保存
使い方
エクスプローラービューでブックファイルを右クリック、またはエディタタイトルのアイコンをクリックして実行します。
Excel ファイルを開く
- エクスプローラービューでブックファイルを選択
- エディタのタイトルから「Open Excel Book」を選択
- Excel でファイルが開く
VBA をロードする
- Excel で編集対象のブックファイルを開く
- VS Code のエクスプローラービューでブックファイルを選択
- エディタのタイトルから「Load VBA from Excel Book」を選択
- ブックファイルと同じ名前のフォルダが作成される
- 例:
MyBook.xlsm → MyBook_xlsm フォルダ
VBA を編集する
フォルダ内の VBA ファイルを VS Code で編集。
差異を確認する
- エクスプローラービューでブックファイルを選択
- エディタのタイトルから「Compare VBA with Excel Book」を選択
- ブックファイルとの差異が表示される
VBA を保存する
- エクスプローラービューでブックファイルを選択
- エディタのタイトルから「Save VBA to Excel Book」を選択
- 編集内容がブックファイルに保存される
Sub プロシージャを実行する
- VBA ファイルをエディタで開く
- 実行したい Sub プロシージャの中にカーソルを置く
- エディタのタイトルから「Run VBA Sub at Cursor」を選択
- 以下の処理が自動的に実行される:
- ブックファイルに VBA の変更内容を保存
- 指定した Sub プロシージャを Excel で実行
CustomUI をロードする
- ブックファイルをエクスプローラービューで選択
- エディタのタイトルから「Load CustomUI from Excel Book」を選択
- アドインファイルと同じ名前のフォルダが作成される
- 例:
MyAddin.xlam → MyAddin_customUI フォルダ
- CustomUI XMLファイル(
customUI.xml, customUI14.xml)が直接フォルダ内に抽出される
CustomUI を編集する
フォルダ内の CustomUI XMLファイル(customUI.xml, customUI14.xml)を VS Code で編集。
CustomUI を保存する(.xlam のみ)
- エクスプローラービューでブックファイルを選択
- エディタのタイトルから「Save CustomUI to Excel Book」を選択
- 編集内容がアドインファイルの CustomUI に保存される
注意事項
- 全般
- ネットからダウンロードしたファイルはアクセスブロックの解除が必要です。
- ブックファイルが壊れた場合に備えてバージョン管理システムで管理してください。
- アドインファイル
- .xlam の場合は拡張機能から直接保存することはできません。VBエディタのツールバーから保存してください。
- VBAファイル
- VBAファイルの文字エンコーティングは Shift_JIS です。
- .frmに対応する.frxは自動生成されます。.frx を削除すると、.frmは保存できません。
- CSVファイル
- 名前に".csv"が付いたシートを処理対象とします。
- 追加
- VBAファイルはVS Codeで新規追加することができます。
- CSVファイルはVS Codeで新規追加することができます。
- CustomUI XMLファイルは新規追加することはできません。事前にブックファイルに登録されている必要があります。
| |