#author("2020-05-06T14:11:12+00:00","default:haikikyou","haikikyou")
#author("2020-05-06T14:12:30+00:00","default:haikikyou","haikikyou")
* Excel VBA [#g0a4f482]

Officeは仕事における重要なツールの1つである。~
表計算ソフトExcelはよく使われるツールであり、VBAを使いこなすことで様々な作業を自動化することができる。~
マクロでコードを自動生成することもできるが、VBAプログラミングの知識があれば、より細かい所まで手が届くようになる。~
以下では、Excel VBAでちょっとしたプログラムを書けるようになるための内容を整理する。~

* アドインの作り方 [#g4258e8d]

リボン付きのアドインの作り方は以下のとおり。

+ vbaプロジェクト生成し、xlsm形式で保存
+ 「名前を付けて保存」で、ファイルの種類をxlam(Excelアドイン形式)で保存~
xlamはzip形式であり、zip形式のアーカイブを解凍すれば中身を展開できる~
&ref(./xlamの展開.PNG);
+ &code(){_rels\.rels};ファイルにリボン定義のリレーションを追加する
#geshi(xml){{{
 <Relationship Id="someID" Type="http://schemas.microsoft.com/office/2006/relationships/ui/extensibility" Target="customUI/customUI.xml" />
}}}
なお、Custom UI Editorというツールが提供されているのでそちらを使うとよい。~
エクセルファイルやアドイン形式のファイルを開いてリボンの編集ができる。~
&label(link){URL}; https://github.com/OfficeDev/office-custom-ui-editor~
また、サンプルも提供されているので参考にするとよい。~
&label(warn){参考}; https://github.com/OfficeDev/office-custom-ui-editor/tree/master/Samples
+ &code(){customUI/customUI.xml};というxml定義ファイルを作成できたら、展開したリソース一式を再度zip形式に圧縮する。拡張子はxlamとすればよい。
+ &code(){customUI/customUI.xml};というxml定義ファイルを作成できたら、展開したリソース一式を再度zip形式に圧縮する。拡張子はxlamとすればよい。(customUIという名前は、上記のRelationship定義で参照名を変えられる:Target)
+ Excelのマクロ形式ブックを開いて、「開発>Excelアドイン」の参照から作成したアドオンを選択すると作成した作成したVBAプロジェクトが使用できるようになる。

&label(warn){参考};

- [[Office Fluent リボンの概要>https://docs.microsoft.com/ja-jp/office/vba/library-reference/concepts/overview-of-the-office-fluent-ribbon]]- &size(11){&color(gray){on https://docs.microsoft.com/ja-jp/office/vba/library-reference/concepts/overview-of-the-office-fluent-ribbon};};
- Custom UI idMso
-- [[3.1.2 Excel 2007>https://docs.microsoft.com/en-us/openspecs/office_standards/ms-customui/bb5bb594-ec8c-45f6-8424-f98e8308b25a]] - &size(11){&color(gray){on https://docs.microsoft.com/en-us/openspecs/office_standards/ms-customui/bb5bb594-ec8c-45f6-8424-f98e8308b25a};};
-- [[7 Index>https://docs.microsoft.com/en-us/openspecs/office_standards/ms-customui/6d119785-9c1b-4cdb-a568-3b03f016cf0f]] - &size(11){&color(gray){on https://docs.microsoft.com/en-us/openspecs/office_standards/ms-customui/6d119785-9c1b-4cdb-a568-3b03f016cf0f};};
* 参考リンク [#dcc8fc5c]

- [[[MS-VBAL]: VBA Language Specification>https://msdn.microsoft.com/en-us/library/dd361851.aspx]] - &size(11){&color(gray){on https://msdn.microsoft.com/en-us/library/dd361851.aspx};};
- [[Office VBA リファレンス>https://docs.microsoft.com/ja-jp/office/vba/api/overview/]] - &size(11){&color(gray){on https://docs.microsoft.com/ja-jp/office/vba/api/overview/};};
- [[Visual Basic for Applications (VBA) の言語リファレンス>https://docs.microsoft.com/ja-jp/office/vba/api/overview/language-reference]] - &size(11){&color(gray){on https://docs.microsoft.com/ja-jp/office/vba/api/overview/language-reference};};
- [[パーフェクト Excel VBA>https://www.amazon.co.jp/exec/obidos/ASIN/4297108755/haikikyou-22/]] - &size(11){&color(gray){on https://www.amazon.co.jp/exec/obidos/ASIN/4297108755/haikikyou-22/};}; &size(9){PR};
-- おすすめ、VBAを基礎から学べる、多くの本はHow Toが多いがこの本はVBAの根本から学べるので応用が効く

** アドイン開発 [#m961cc70]

- [[OfficeDev / office-custom-ui-editor>https://github.com/OfficeDev/office-custom-ui-editor]] - &size(11){&color(gray){on https://github.com/OfficeDev/office-custom-ui-editor};};

トップ   差分 バックアップ リロード   一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
目次
ダブルクリックで閉じるTOP | 閉じる
GO TO TOP