コード ウィンドウCode window
Visual Basic のコードを作成、表示、編集するには、コード ウィンドウを使用します。Use the Code window to write, display, and edit Visual Basic code. モジュールと同じ数だけコード ウィンドウを開くことができるので、異なるフォームまたはモジュールのコードを簡単に表示し、それらの間でコピーと貼り付けを行うことができます。You can open as many Code windows as you have modules, so you can easily view the code in different forms or modules, and copy and paste between them.
コード ウィンドウは次のようにして開くことができます。You can open a Code window from:
- [プロジェクト] ウィンドウで、フォームまたはモジュールを選択し、[コードの表示] ボタンを選択します。The Project window, by selecting a form or module, and choosing the View Code button.
- UserForm ウィンドウで、コントロールまたはフォームをダブルクリックし、[表示] メニューの [コード] を選択するか、F7 キーを押します。A UserForm window, by double-clicking a control or form, choosing Code from the View menu, or pressing F7.
選択したテキストを次の場所にドラッグできます。You can drag selected text to:
- 現在のコード ウィンドウの別の場所。A different location in the current Code window.
- 別のコード ウィンドウ。Another Code window.
- [イミディエイト] ウィンドウおよび [ウォッチ] ウィンドウ。The Immediate and Watch windows.
- ごみ箱。The Recycle Bin.
ウィンドウ要素Window elements
要素Element | アイコンIcon | 説明Description |
---|---|---|
オブジェクト ボックスObject box | 選択したオブジェクトの名前が表示されます。Displays the name of the selected object. リスト ボックスの右側にある矢印をクリックすると、フォームに関連付けられているすべてのオブジェクトの一覧が表示されます。Click the arrow to the right of the list box to display a list of all objects associated with the form. | |
プロシージャ/イベント ボックスProcedures/Events box | オブジェクト ボックスに表示されているフォームまたはコントロールに対して Visual Basic で認識されるすべてのイベントの一覧が表示されます。Lists all the events recognized by Visual Basic for a form or control displayed in the Object box. イベントを選択すると、そのイベント名に関連付けられているイベント プロシージャがコード ウィンドウに表示されます。When you select an event, the event procedure associated with that event name is displayed in the Code window. オブジェクト ボックスに [(General)] と表示されている場合は、プロシージャ ボックスには、そのフォームに対して作成されているすべての宣言およびすべての一般プロシージャが一覧表示されます。If (General) is displayed in the Object box, the Procedure box lists any declarations and all of the general procedures that have been created for the form. モジュールのコードを編集している場合は、プロシージャ ボックスにはモジュールに含まれるすべての一般プロシージャが一覧表示されます。If you are editing module code, the Procedure box lists all of the general procedures in the module. いずれの場合も、プロシージャ ボックスで選択したプロシージャがコード ウィンドウに表示されます。In either case, the procedure you select in the Procedure box is displayed in the Code window. モジュールのすべてのプロシージャが、単一のスクロール可能なリストに、名前のアルファベット順で表示されます。All the procedures in a module appear in a single, scrollable list that is sorted alphabetically by name. コード ウィンドウの上部にあるドロップダウン リスト ボックスを使用してプロシージャを選択すると、選択したプロシージャの最初の行にカーソルが移動します。Selecting a procedure by using the drop-down list boxes at the top of the Code window moves the cursor to the first line of code in the procedure you select. |
|
分割バーSplit bar | このバーを下にドラッグすると、コード ウィンドウが 2 つの水平方向のウィンドウに分割されて、それぞれを個別にスクロールできます。Dragging this bar down splits the Code window into two horizontal panes, each of which scrolls separately. コードの異なる部分を同時に表示できます。You can then view different parts of your code at the same time. オブジェクト ボックスとプロシージャ/イベント ボックスに表示される情報は、フォーカスが設定されているウィンドウのコードに対するものです。The information that appears in the Object box and Procedures/Events box applies to the code in the pane that has the focus. バーをウィンドウの上端または下端までドラッグするか、バーをダブルクリックすると、ウィンドウが閉じます。Dragging the bar to the top or the bottom of the window or double-clicking the bar closes a pane. | |
余白のインジケーター バーMargin Indicator bar | コード ウィンドウの左側にある灰色の領域には、余白のインジケーターが表示されます。A gray area on the left side of the Code window where margin indicators are displayed. | |
[プロシージャの表示] アイコンProcedure View icon | ![]() |
選択したプロシージャが表示されます。Displays the selected procedure. コード ウィンドウに表示されるプロシージャは一度に 1 つだけです。Only one procedure at a time is displayed in the Code window. |
[モジュール全体を連続表示] アイコンFull Module View icon | ![]() |
モジュールのコード全体が表示されます。Displays the entire code in the module. |
キーボード ショートカットKeyboard shortcuts
以下のショートカット キーを使用して、コード ウィンドウのコマンドにアクセスできます。You can use the following shortcut keys to access commands in the Code window.
説明Description | ショートカット キーShortcut keys |
---|---|
コード ウィンドウの表示View Code window | F7F7 |
オブジェクト ブラウザーの表示View Object Browser | F2F2 |
検索Find | Ctrl + FCTRL+F |
ReplaceReplace | Ctrl + HCTRL+H |
次を検索Find Next | F3F3 |
前を検索Find Previous | Shift + F3SHIFT+F3 |
次のプロシージャNext procedure | Ctrl + ↓CTRL+DOWN ARROW |
前のプロシージャPrevious procedure | Ctrl + ↑CTRL+UP ARROW |
ビューの定義View definition | Shift + F2SHIFT+F2 |
1 画面分下に移動Shift one screen down | Ctrl + PageDownCTRL+PAGE DOWN |
1 画面分上に移動Shift one screen up | Ctrl + PageUpCTRL+PAGE UP |
元の位置へ移動Go to last position | Ctrl + Shift + F2CTRL+SHIFT+F2 |
モジュールの先頭Beginning of module | Ctrl + HomeCTRL+HOME |
モジュールの末尾End of module | Ctrl + EndCTRL+END |
次の語に移動Move one word to right | Ctrl + →CTRL+RIGHT ARROW |
前の語に移動Move one word to left | Ctrl + ←CTRL+LEFT ARROW |
行末に移動Move to end of line | 終了END |
行頭に移動Move to beginning of line | ホームHOME |
元に戻すUndo | Ctrl + ZCTRL+Z |
現在の行を削除Delete current line | Ctrl + YCTRL+Y |
語末まで削除Delete to end of word | Ctrl + DelCTRL+DELETE |
インデントIndent | TabTAB |
インデントを戻すOutdent | Shift + TabSHIFT+TAB |
すべてのブレークポイントの解除Clear all breakpoints | Ctrl + Shift + F9CTRL+SHIFT+F9 |
ショートカット メニューの表示View shortcut menu | Shift + F10SHIFT+F10 |
関連項目See also
- コード ウィンドウの編集キーCode window editing keys
- コード ウィンドウの汎用キーCode window general use keys
- コード ウィンドウのメニュー ショートカット キーCode window menu shortcut keys
- コード ウィンドウのナビゲーション キーCode window navigation keys
- コード ウィンドウとオブジェクト ブラウザーのアイコンCode window and Object Browser icons
- コード ウィンドウを分割するSplit the Code window
- ウィンドウ要素Window elements
サポートとフィードバックSupport and feedback
Office VBA またはこの説明書に関するご質問やフィードバックがありますか?Have questions or feedback about Office VBA or this documentation? サポートの受け方およびフィードバックをお寄せいただく方法のガイダンスについては、Office VBA のサポートおよびフィードバックを参照してください。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.