{"id":4878,"date":"2016-01-20T09:00:33","date_gmt":"2016-01-20T00:00:33","guid":{"rendered":"http:\/\/excelwork.info\/excel\/?p=4878"},"modified":"2016-01-20T09:11:21","modified_gmt":"2016-01-20T00:11:21","slug":"vbcomponents","status":"publish","type":"post","link":"https:\/\/excelwork.info\/excel\/vbcomponents\/","title":{"rendered":"VBE\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u53c2\u7167\u3059\u308b\uff08VBComponents \u30b3\u30ec\u30af\u30b7\u30e7\u30f3\uff09"},"content":{"rendered":"<h2>VBComponents \u30b3\u30ec\u30af\u30b7\u30e7\u30f3<\/h2>\n<div class=\"m30-l\">\n<p><strong>VBComponents \u30b3\u30ec\u30af\u30b7\u30e7\u30f3<\/strong>\u3092\u4f7f\u7528\u3059\u308b\u3068\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\uff08\u6a19\u6e96\u30e2\u30b8\u30e5\u30fc\u30eb\u3001\u30af\u30e9\u30b9\u30e2\u30b8\u30e5\u30fc\u30eb\u3001\u30e6\u30fc\u30b6\u30fc\u30d5\u30a9\u30fc\u30e0\uff09\u306e\u8ffd\u52a0\u30fb\u524a\u9664\u3092\u884c\u3063\u305f\u308a\u3001\u53c2\u7167\u3057\u305f\u308a\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<br \/>\n<div class=\"kkbox\"><strong>\u3010\u66f8\u5f0f\u3011<\/strong><\/p>\n<p>    <em>object<\/em>.<strong>VBComponents<\/strong><\/p><\/div>\n<br \/>\n<h4>\u5f15\u6570\u30fb\u623b\u308a\u5024<\/h4>\n<div class=\"m30-l\">\n<ul style=\"margin-top:0;margin-bottom:0;padding-top:0;padding-bottom:0;\">\n<li>object&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u5bfe\u8c61\u3068\u306a\u308b <span class=\"red\"><strong>VBProject \u30aa\u30d6\u30b8\u30a7\u30af\u30c8<\/strong><\/span>\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/li>\n<\/ul><\/div>\n<br \/>\n<p class=\"caution4\"><strong>VBProject \u30d7\u30ed\u30d1\u30c6\u30a3<\/strong>\u3092\u4f7f\u7528\u3059\u308b\u306b\u306f\u3001\u4e8b\u524d\u306b\u8a2d\u5b9a\u304c\u5fc5\u8981\u3067\u3059\u3002\u8a73\u7d30\u306f\u3001<a href=\"https:\/\/excelwork.info\/excel\/vbevbprojectsettings\/\">VBE \u3092\u30de\u30af\u30ed\u3067\u64cd\u4f5c\u3059\u308b\u6642\u306e\u8a2d\u5b9a\uff08VBProject \u30d7\u30ed\u30d1\u30c6\u30a3\u3001VBE \u30d7\u30ed\u30d1\u30c6\u30a3\uff09<\/a> \u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<\/div>\n<br \/><br \/>\n<h2>VBComponents \u306e\u4e3b\u306a\u30e1\u30bd\u30c3\u30c9<\/h2>\n<div class=\"m30-l\">\n<br \/>\n<h3>VBComponents.Add \u30e1\u30bd\u30c3\u30c9<\/h3>\n<p>\u6307\u5b9a\u3057\u305f\u7a2e\u985e\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<strong>VBComponents.Add \u30e1\u30bd\u30c3\u30c9<\/strong>\u306f\u3001<strong>VBComponent \u30aa\u30d6\u30b8\u30a7\u30af\u30c8<\/strong>\u3092\u8fd4\u3057\u307e\u3059\u3002<\/p>\n<br \/>\n<div class=\"kkbox\"><strong>\u3010\u66f8\u5f0f\u3011<\/strong><\/p>\n<p>    <em>object<\/em>.<strong>Add<\/strong> ( <em>component<\/em> )<\/p><\/div>\n<br \/>\n<h4>\u5f15\u6570\u30fb\u623b\u308a\u5024<\/h4>\n<div class=\"m30-l\">\n<ul style=\"margin-top:0;margin-bottom:0;padding-top:0;padding-bottom:0;\">\n<li>object&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u5bfe\u8c61\u3068\u306a\u308b <span class=\"red\"><strong>VBComponents \u30aa\u30d6\u30b8\u30a7\u30af\u30c8<\/strong><\/span>\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/li>\n<li>component&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u7a2e\u985e\u3092\u8868\u3059\u6570\u5024\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<br \/>\n<table>\n<tr>\n<td align = \"center\" width=\"50\" bgcolor=\"#ffffccc\"><strong>\u5024<\/strong><\/td>\n<td align = \"center\" width=\"200\" bgcolor=\"#ffffccc\"><strong>\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u7a2e\u985e<\/strong><\/td>\n<td align = \"center\" width=\"400\" bgcolor=\"#ffffccc\"><strong>\u4f8b<\/strong><\/td>\n<\/tr>\n<tr>\n<td width=\"50\" align = \"center\">1<\/td>\n<td width=\"200\">\u6a19\u6e96\u30e2\u30b8\u30e5\u30fc\u30eb<\/td>\n<td width=\"400\">\u300cModule1\u300d\u300cModule2\u300d\u306a\u3069<\/td>\n<\/tr>\n<tr>\n<td width=\"50\" align = \"center\">2<\/td>\n<td width=\"200\">\u30af\u30e9\u30b9\u30e2\u30b8\u30e5\u30fc\u30eb<\/td>\n<td width=\"400\">\u300cClass1\u300d\u300cClass2\u300d\u306a\u3069<\/td>\n<\/tr>\n<tr>\n<td width=\"50\" align = \"center\">3<\/td>\n<td width=\"200\">\u30e6\u30fc\u30b6\u30fc\u30d5\u30a9\u30fc\u30e0<\/td>\n<td width=\"400\">\u300cUserForm1\u300d\u300cUserForm2\u300d\u306a\u3069<\/td>\n<\/tr>\n<\/table>\n<\/li>\n<\/ul><\/div>\n<br \/>\n<h3>VBComponents.Remove \u30e1\u30bd\u30c3\u30c9<\/h3>\n<p>\u5f15\u6570\u3067\u6307\u5b9a\u3057\u305f\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u958b\u653e\uff08\u524a\u9664\uff09\u3057\u307e\u3059\u3002<\/p>\n<br \/>\n<div class=\"kkbox\"><strong>\u3010\u66f8\u5f0f\u3011<\/strong><\/p>\n<p>    <em>object<\/em>.<strong>Remove<\/strong> ( <em>vbcomponent<\/em> )<\/p><\/div>\n<br \/>\n<h4>\u5f15\u6570\u30fb\u623b\u308a\u5024<\/h4>\n<div class=\"m30-l\">\n<ul style=\"margin-top:0;margin-bottom:0;padding-top:0;padding-bottom:0;\">\n<li>object&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u5bfe\u8c61\u3068\u306a\u308b <span class=\"red\"><strong>VBComponents \u30aa\u30d6\u30b8\u30a7\u30af\u30c8<\/strong><\/span>\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/li>\n<li>vbcomponent&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u524a\u9664\u3059\u308b\u30e2\u30b8\u30e5\u30fc\u30eb\uff08<strong>VBComponent \u578b<\/strong>\uff09\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/li>\n<\/ul><\/div>\n<br \/>\n<h3>VBComponents.Import \u30e1\u30bd\u30c3\u30c9<\/h3>\n<p>\u30a8\u30af\u30b9\u30dd\u30fc\u30c8\u3055\u308c\u305f\u30e2\u30b8\u30e5\u30fc\u30eb\uff08\u30d5\u30a1\u30a4\u30eb\uff09\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3057\u307e\u3059\u3002<\/p>\n<br \/>\n<div class=\"kkbox\"><strong>\u3010\u66f8\u5f0f\u3011<\/strong><\/p>\n<p>    <em>object<\/em>.<strong>Import<\/strong> ( <em>filename<\/em> )<\/p><\/div>\n<br \/>\n<h4>\u5f15\u6570\u30fb\u623b\u308a\u5024<\/h4>\n<div class=\"m30-l\">\n<ul style=\"margin-top:0;margin-bottom:0;padding-top:0;padding-bottom:0;\">\n<li>object&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u5bfe\u8c61\u3068\u306a\u308b <span class=\"red\"><strong>VBComponents \u30aa\u30d6\u30b8\u30a7\u30af\u30c8<\/strong><\/span>\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/li>\n<li>filename&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u30a4\u30f3\u30dd\u30fc\u30c8\u3059\u308b\u30d5\u30a1\u30a4\u30eb\u306e\u30d1\u30b9\u3068\u540d\u524d\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<br \/>\n\t\u30fb\u6a19\u6e96\u30e2\u30b8\u30e5\u30fc\u30eb\uff08.bas \u30d5\u30a1\u30a4\u30eb\uff09<br \/>\n\t\u30fb\u30af\u30e9\u30b9\u30e2\u30b8\u30e5\u30fc\u30eb\uff08.cls \u30d5\u30a1\u30a4\u30eb\uff09<br \/>\n\t\u30fb\u30e6\u30fc\u30b6\u30fc\u30d5\u30a9\u30fc\u30e0\uff08.frm \u30d5\u30a1\u30a4\u30eb\uff09\n      <\/li>\n<\/ul><\/div>\n<br \/>\n<h3>VBComponents.Item \u30e1\u30bd\u30c3\u30c9<\/h3>\n<p><strong>VBComponents \u30b3\u30ec\u30af\u30b7\u30e7\u30f3<\/strong>\u304b\u3089\u5358\u4e00\u306e <strong>VBComponent \u30aa\u30d6\u30b8\u30a7\u30af\u30c8<\/strong>\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n<br \/>\n<div class=\"kkbox\"><strong>\u3010\u66f8\u5f0f\u3011<\/strong><\/p>\n<p>    <em>object<\/em>[.<strong>Item<\/strong>]( <em>index<\/em> )<\/p><\/div>\n<br \/>\n<h4>\u5f15\u6570\u30fb\u623b\u308a\u5024<\/h4>\n<div class=\"m30-l\">\n<ul style=\"margin-top:0;margin-bottom:0;padding-top:0;padding-bottom:0;\">\n<li>object&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u5bfe\u8c61\u3068\u306a\u308b <span class=\"red\"><strong>VBComponents \u30aa\u30d6\u30b8\u30a7\u30af\u30c8<\/strong><\/span>\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/li>\n<li>index&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;1 \u304b\u3089\u306f\u3058\u307e\u308b\u6574\u6570\u5024\u307e\u305f\u306f\u3001\u30e2\u30b8\u30e5\u30fc\u30eb\u540d\uff08\u6587\u5b57\u5217\uff09\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/li>\n<\/ul><\/div>\n<br \/>\n<p class=\"caution4\"><strong>VBComponents.Item<\/strong>\u306e\u8a73\u7d30\u306b\u95a2\u3057\u3066\u306f\u3001<a href=\"https:\/\/excelwork.info\/excel\/vbcomponent\/\">\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u64cd\u4f5c\u3059\u308b\uff08VBComponent \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\uff09<\/a>\u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<\/div>\n<br \/><br \/>\n<h2>VBComponents \u306e\u4e3b\u306a\u30d7\u30ed\u30d1\u30c6\u30a3<\/h2>\n<div class=\"m30-l\">\n<br \/>\n<h3>VBComponents.Count \u30d7\u30ed\u30d1\u30c6\u30a3<\/h3>\n<p>\u30e2\u30b8\u30e5\u30fc\u30eb\uff08\u6a19\u6e96\u30e2\u30b8\u30e5\u30fc\u30eb\u3001\u30af\u30e9\u30b9\u30e2\u30b8\u30e5\u30fc\u30eb\u3001\u30e6\u30fc\u30b6\u30fc\u30d5\u30a9\u30fc\u30e0\u3001\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u30e2\u30b8\u30e5\u30fc\u30eb\uff09\u306e\u7dcf\u6570\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n<br \/>\n<div class=\"kkbox\"><strong>\u3010\u66f8\u5f0f\u3011<\/strong><\/p>\n<p>    <em>object<\/em>.<strong>Count<\/strong><\/p><\/div>\n<br \/>\n<h4>\u5f15\u6570\u30fb\u623b\u308a\u5024<\/h4>\n<div class=\"m30-l\">\n<ul style=\"margin-top:0;margin-bottom:0;padding-top:0;padding-bottom:0;\">\n<li>object&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u5bfe\u8c61\u3068\u306a\u308b <span class=\"red\"><strong>VBComponents \u30aa\u30d6\u30b8\u30a7\u30af\u30c8<\/strong><\/span>\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/li>\n<\/ul><\/div>\n<\/div>\n<br \/><br \/>\n<h2>VBComponents \u4f7f\u7528\u4f8b<\/h2>\n<div class=\"m30-l\">\n<h3 id=\"vba_sample\">\u30b5\u30f3\u30d7\u30ebVBA\u30bd\u30fc\u30b9<\/h3>\n<pre class=\"lang:vb mark:0 decode:true \" title=\"VBComponents \u4f7f\u7528\u4f8b\" data-url=\"http:\/\/example.co.jp\" >\r\n\u3000\r\nSub Sample_VBComponents()\r\n\r\n    Dim FileName As String\r\n    Dim w As Workbook\r\n    Dim v As Object\r\n    Dim stdm1 As Object\r\n    Dim stdm2 As Object\r\n    Dim stdm3 As Object\r\n    Dim str As String\r\n    \r\n    FileName = \"C:\\Documents\\test.xlsm\"\r\n    \r\n    '\u30d6\u30c3\u30af\uff08test.xlsm\uff09\u3092\u30aa\u30fc\u30d7\u30f3\r\n    Set w = Workbooks.Open(FileName)\r\n\r\n    With w.VBProject\r\n\r\n        .VBE.Windows(1).SetFocus\r\n        \r\n        '\u6a19\u6e96\u30e2\u30b8\u30e5\u30fc\u30eb\uff08Module1\uff09\u3092\u8ffd\u52a0\r\n        Set stdm1 = .VBComponents.Add(1)\r\n        \r\n        '\u6a19\u6e96\u30e2\u30b8\u30e5\u30fc\u30eb\uff08Module2\uff09\u3092\u8ffd\u52a0\r\n        Set stdm2 = .VBComponents.Add(1)\r\n        \r\n        '\u6a19\u6e96\u30e2\u30b8\u30e5\u30fc\u30eb\uff08Module3\uff09\u3092\u8ffd\u52a0\r\n        Set stdm3 = .VBComponents.Add(1)\r\n    \r\n    \r\n        '\u6a19\u6e96\u30e2\u30b8\u30e5\u30fc\u30eb\uff08Module1\uff09\u3092\u524a\u9664\r\n        .VBComponents.Remove w.VBProject.VBComponents(\"Module1\")\r\n    \r\n        '\u6a19\u6e96\u30e2\u30b8\u30e5\u30fc\u30eb\uff08Module3\uff09\u3092\u524a\u9664\r\n        .VBComponents.Remove stdm3\r\n    \r\n        '\u30af\u30e9\u30b9\u30e2\u30b8\u30e5\u30fc\u30eb\uff08Class1.cls\uff09\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\r\n        .VBComponents.Import (\"c:\\Documents\\Class1.cls\")\r\n    \r\n        '\u30e6\u30fc\u30b6\u30fc\u30d5\u30a9\u30fc\u30e0\uff08UserForm1.frm\uff09\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\r\n        .VBComponents.Import (\"c:\\Documents\\UserForm1.frm\")\r\n    \r\n        '\u3059\u3079\u3066\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u540d\u3092\u53d6\u5f97\r\n        For Each v In .VBComponents\r\n        \r\n            str = str & v.Name & vbCrLf\r\n        \r\n        Next v\r\n        \r\n        '\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u6570\r\n        str = str & \"\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u7dcf\u6570\uff1a\" & .VBComponents.Count\r\n    \r\n    End With\r\n    \r\n    w.Saved = True\r\n    w.Close\r\n    Set w = Nothing\r\n    \r\n    '\u30e2\u30b8\u30e5\u30fc\u30eb\u540d\u8868\u793a\r\n    MsgBox str\r\n\r\nEnd Sub\r\n\u3000\r\n  <\/pre>\n<br \/>\n<h3>\u5b9f\u884c\u7d50\u679c<\/h3>\n<p><a href=\"https:\/\/i0.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2016\/01\/vbcomponents-01.jpg?ssl=1\" rel=\"lightbox[4878]\"><img loading=\"lazy\" src=\"https:\/\/i0.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2016\/01\/vbcomponents-01.jpg?resize=168%2C230&#038;ssl=1\" alt=\"VBComponents \u30b3\u30ec\u30af\u30b7\u30e7\u30f3\" width=\"168\" height=\"230\" class=\"alignnone size-full wp-image-4922\" data-recalc-dims=\"1\" \/><\/a><\/p>\n<\/div>\n<br \/><br \/>\n","protected":false},"excerpt":{"rendered":"<p>VBComponents \u30b3\u30ec\u30af\u30b7\u30e7\u30f3 VBComponents \u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u3092 &#8230; <\/p>\n","protected":false},"author":1,"featured_media":4922,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"amp_status":"","spay_email":"","jetpack_publicize_message":""},"categories":[696],"tags":[63,751,755,753,754,752,698,749,750,363,38],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2016\/01\/vbcomponents-01.jpg?fit=168%2C230&ssl=1","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p4Ye9i-1gG","_links":{"self":[{"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/posts\/4878"}],"collection":[{"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/comments?post=4878"}],"version-history":[{"count":14,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/posts\/4878\/revisions"}],"predecessor-version":[{"id":4980,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/posts\/4878\/revisions\/4980"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/media\/4922"}],"wp:attachment":[{"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/media?parent=4878"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/categories?post=4878"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/tags?post=4878"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}