{"id":10089,"date":"2018-03-02T12:15:10","date_gmt":"2018-03-02T03:15:10","guid":{"rendered":"https:\/\/www.ka-net.org\/blog\/?p=10089"},"modified":"2018-03-02T14:33:32","modified_gmt":"2018-03-02T05:33:32","slug":"office%e3%82%a2%e3%83%89%e3%82%a4%e3%83%b3%e3%83%af%e3%83%bc%e3%82%af%e3%82%b7%e3%83%bc%e3%83%88%e3%81%a7%e9%81%b8%e6%8a%9e%e7%af%84%e5%9b%b2%e3%82%92%e5%a4%89%e6%9b%b4%e3%81%97%e3%81%9f%e3%81%a8","status":"publish","type":"post","link":"https:\/\/www.ka-net.org\/blog\/?p=10089","title":{"rendered":"[Office\u30a2\u30c9\u30a4\u30f3]\u30ef\u30fc\u30af\u30b7\u30fc\u30c8\u3067\u9078\u629e\u7bc4\u56f2\u3092\u5909\u66f4\u3057\u305f\u3068\u304d\u306b\u767a\u751f\u3059\u308b\u30a4\u30d9\u30f3\u30c8"},"content":{"rendered":"<p>\u30ef\u30fc\u30af\u30b7\u30fc\u30c8\u4e0a\u3067\u9078\u629e\u7bc4\u56f2\u306e\u5909\u66f4\u3092\u691c\u77e5\u3059\u308b\u969b\u3001VBA\u3067\u306f\u901a\u5e38\u300c<a href=\"https:\/\/msdn.microsoft.com\/ja-jp\/vba\/excel-vba\/articles\/worksheet-selectionchange-event-excel\" title=\"Worksheet.SelectionChange \u30a4\u30d9\u30f3\u30c8 (Excel)\" target=\"_blank\">Worksheet.SelectionChange<\/a>\u300d\u30a4\u30d9\u30f3\u30c8\u3092\u5229\u7528\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">Private Sub Worksheet_SelectionChange(ByVal Target As Range)\r\n  Debug.Print Target.Address\r\nEnd Sub<\/pre>\n<p>Office \u30a2\u30c9\u30a4\u30f3\u3067\u3082\u540c\u69d8\u306b\u3001\u30a4\u30d9\u30f3\u30c8\u30cf\u30f3\u30c9\u30e9\u3092\u8ffd\u52a0\u3059\u308b\u3053\u3068\u306b\u3088\u3063\u3066\u3001\u9078\u629e\u7bc4\u56f2\u306e\u5909\u66f4\u3092\u691c\u77e5\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h4 class=\"style4a\">\u30de\u30cb\u30d5\u30a7\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb(manifest.xml)<\/h4>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;\r\n&lt;OfficeApp xmlns=&quot;http:\/\/schemas.microsoft.com\/office\/appforoffice\/1.1&quot; xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot; xsi:type=&quot;TaskPaneApp&quot;&gt;\r\n  &lt;Id&gt;c578d697-f2bc-4eea-9d44-68a35fc24d39&lt;\/Id&gt;\r\n  &lt;Version&gt;1.0&lt;\/Version&gt;\r\n  &lt;ProviderName&gt;@kinuasa&lt;\/ProviderName&gt;\r\n  &lt;DefaultLocale&gt;ja-jp&lt;\/DefaultLocale&gt;\r\n  &lt;DisplayName DefaultValue=&quot;\u30a4\u30d9\u30f3\u30c8\u30b5\u30f3\u30d7\u30eb&quot; \/&gt;\r\n  &lt;Description DefaultValue=&quot;Work with Events using the Excel JavaScript API&quot;\/&gt;\r\n  &lt;Hosts&gt;\r\n    &lt;Host Name=&quot;Workbook&quot; \/&gt;\r\n  &lt;\/Hosts&gt;\r\n  &lt;DefaultSettings&gt;\r\n    &lt;SourceLocation DefaultValue=&quot;https:\/\/localhost\/apps\/test0301\/index.html&quot; \/&gt;\r\n  &lt;\/DefaultSettings&gt;\r\n  &lt;Permissions&gt;ReadWriteDocument&lt;\/Permissions&gt;\r\n&lt;\/OfficeApp&gt;<\/pre>\n<h4 class=\"style4a\">\u30a2\u30c9\u30a4\u30f3\u672c\u4f53(index.html)<\/h4>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n  &lt;head&gt;\r\n    &lt;meta charset=&quot;UTF-8&quot;&gt;\r\n    &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=Edge&quot;&gt;\r\n    &lt;title&gt;Sample&lt;\/title&gt;\r\n    &lt;link rel=&quot;stylesheet&quot; href=&quot;https:\/\/static2.sharepointonline.com\/files\/fabric\/office-ui-fabric-js\/1.4.0\/css\/fabric.components.min.css&quot;&gt;\r\n    &lt;style&gt;\r\n      #content-main {\r\n        background: #ffffff;\r\n        position: fixed;\r\n        top: 200px;\r\n        left: 0;\r\n        right: 0;\r\n        bottom: 0;\r\n        overflow: auto;\r\n      }\r\n    &lt;\/style&gt;\r\n    &lt;script src=&quot;https:\/\/ajax.aspnetcdn.com\/ajax\/jquery\/jquery-3.3.1.min.js&quot;&gt;&lt;\/script&gt;\r\n    &lt;!-- &lt;script src=&quot;https:\/\/appsforoffice.microsoft.com\/lib\/1\/hosted\/office.js&quot;&gt;&lt;\/script&gt; --&gt;\r\n    &lt;script src=&quot;https:\/\/appsforoffice.microsoft.com\/lib\/beta\/hosted\/office.js&quot;&gt;&lt;\/script&gt;\r\n    &lt;script src=&quot;https:\/\/unpkg.com\/core-js\/client\/core.min.js&quot;&gt;&lt;\/script&gt;\r\n    &lt;script src=&quot;https:\/\/unpkg.com\/@microsoft\/office-js-helpers@0.7.4\/dist\/office.helpers.min.js&quot;&gt;&lt;\/script&gt;\r\n    &lt;script src=&quot;https:\/\/static2.sharepointonline.com\/files\/fabric\/office-ui-fabric-js\/1.4.0\/js\/fabric.min.js&quot;&gt;&lt;\/script&gt;\r\n    &lt;script&gt;\r\n      var eventResult;\r\n      \r\n      Office.initialize = function(reason){\r\n        $(document).ready(function(){\r\n          $(&quot;#btn1&quot;).click(regOnSelectionChanged);\r\n          $(&quot;#btn2&quot;).click(removeOnSelectionChanged);\r\n        });\r\n      };\r\n       \r\n      function regOnSelectionChanged(){\r\n        Excel.run(function(context){\r\n          var sht = context.workbook.worksheets.getActiveWorksheet();\r\n          eventResult = sht.onSelectionChanged.add(sht_onSelectionChanged);\r\n          return context.sync().then(function(){\r\n            OfficeHelpers.UI.notify(&quot;&quot;, &quot;\u30a4\u30d9\u30f3\u30c8\u30cf\u30f3\u30c9\u30e9\u306e\u8ffd\u52a0\u6210\u529f&quot;, &quot;success&quot;);\r\n          });\r\n        }).catch(function(error){\r\n          OfficeHelpers.UI.notify(error);\r\n        });\r\n      }\r\n      \r\n      function removeOnSelectionChanged(){\r\n        return Excel.run(eventResult.context, function(context){\r\n          eventResult.remove();\r\n          return context.sync().then(function(){\r\n            eventResult = null;\r\n            OfficeHelpers.UI.notify(&quot;&quot;, &quot;\u30a4\u30d9\u30f3\u30c8\u30cf\u30f3\u30c9\u30e9\u306e\u524a\u9664\u6210\u529f&quot;, &quot;success&quot;);\r\n          });\r\n        }).catch(function(error){\r\n          OfficeHelpers.UI.notify(error);\r\n        });\r\n      }\r\n      \r\n      function sht_onSelectionChanged(event){\r\n        return Excel.run(function(context){\r\n          return context.sync().then(function(){\r\n            OfficeHelpers.UI.notify(&quot;&quot;, &quot;type:&quot; + event.type + \r\n                                        &quot;\\naddress:&quot; + event.address + \r\n                                        &quot;\\nworksheetId:&quot; + event.worksheetId, &quot;success&quot;);\r\n          });\r\n        }).catch(function(error){\r\n          OfficeHelpers.UI.notify(error);\r\n        });\r\n      }\r\n    &lt;\/script&gt;\r\n  &lt;\/head&gt;\r\n  &lt;body&gt;\r\n    &lt;div id=&quot;content-main&quot;&gt;\r\n      &lt;button id=&quot;btn1&quot; class=&quot;ms-Button&quot;&gt;\r\n        &lt;span class=&quot;ms-Button-label&quot;&gt;Reg onSelectionChanged&lt;\/span&gt;\r\n      &lt;\/button&gt;\r\n      &lt;button id=&quot;btn2&quot; class=&quot;ms-Button&quot;&gt;\r\n        &lt;span class=&quot;ms-Button-label&quot;&gt;Remove onSelectionChanged&lt;\/span&gt;\r\n      &lt;\/button&gt;\r\n    &lt;\/div&gt;\r\n  &lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>\u8ffd\u52a0\u3057\u305f\u30a4\u30d9\u30f3\u30c8\u30cf\u30f3\u30c9\u30e9\u306f\u3001\u4e0a\u8a18\u30b3\u30fc\u30c9\u306e\u3088\u3046\u306bremove\u30e1\u30bd\u30c3\u30c9\u3067\u524a\u9664\u3001\u3082\u3057\u304f\u306f\u30a2\u30c9\u30a4\u30f3\u3092\u7d42\u4e86\u3057\u305f\u969b\u306b\u7834\u68c4\u3055\u308c\u308b\u305f\u3081\u3001\u30d5\u30a1\u30a4\u30eb\u306b\u30a4\u30d9\u30f3\u30c8\u304c\u4fdd\u6301\u3055\u308c\u308b\u3053\u3068\u306f\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n<p><a href=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/onSelectionChanged_Events_OfficeAdd-ins_01.gif\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/onSelectionChanged_Events_OfficeAdd-ins_01.gif\" alt=\"\" width=\"693\" height=\"515\" class=\"alignnone size-full wp-image-10090\" \/><\/a><\/p>\n<h4 class=\"style4a\">\u53c2\u8003Web\u30da\u30fc\u30b8<\/h4>\n<ul>\n<li>Work with Events using the Excel JavaScript API<\/li>\n<li style=\"list-style-type:none;\"><a href=\"https:\/\/docs.microsoft.com\/en-us\/office\/dev\/add-ins\/excel\/excel-add-ins-events\" target=\"_blank\" title=\"Work with Events using the Excel JavaScript API\">https:\/\/docs.microsoft.com\/en-us\/office\/dev\/add-ins\/excel\/excel-add-ins-events<\/a><\/li>\n<\/ul>\n<div id=\"single_banner_area2\" class=\"clearfix one_banner\">\n<div class=\"single_banner single_banner_left\">\n<script async src=\"https:\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script>\r\n<!-- \u8a18\u4e8b\u4e2d(\u30c7\u30a3\u30b9\u30d7\u30ec\u30a4\u5e83\u544a\u30e6\u30cb\u30c3\u30c8) -->\r\n<ins class=\"adsbygoogle\"\r\n     style=\"display:block\"\r\n     data-ad-client=\"ca-pub-7306936664602087\"\r\n     data-ad-slot=\"5429724765\"\r\n     data-ad-format=\"auto\"\r\n     data-full-width-responsive=\"true\"><\/ins>\r\n<script>\r\n     (adsbygoogle = window.adsbygoogle || []).push({});\r\n<\/script>\n<\/div>\n<div class=\"single_banner single_banner_right\">\n<a href=\"\" target=\"_blank\"><img decoding=\"async\" src=\"\" alt=\"\" title=\"\" \/><\/a>\n<\/div>\n<\/div>\n\n","protected":false},"excerpt":{"rendered":"\u30ef\u30fc\u30af\u30b7\u30fc\u30c8\u4e0a\u3067\u9078\u629e\u7bc4\u56f2\u306e\u5909\u66f4\u3092\u691c\u77e5\u3059\u308b\u969b\u3001VBA\u3067\u306f\u901a\u5e38\u300cWorksheet.SelectionChange\u300d\u30a4\u30d9\u30f3\u30c8\u3092\u5229\u7528\u3057\u307e\u3059\u3002 Private Sub Worksheet_SelectionChange(ByVa [&hellip;]","protected":false},"author":1,"featured_media":7119,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"[[Office\u30a2\u30c9\u30a4\u30f3]\u30ef\u30fc\u30af\u30b7\u30fc\u30c8\u3067\u9078\u629e\u7bc4\u56f2\u3092\u5909\u66f4\u3057\u305f\u3068\u304d\u306b\u767a\u751f\u3059\u308b\u30a4\u30d9\u30f3\u30c8]","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[130,4,48],"tags":[],"class_list":["post-10089","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-apps-for-office","category-office","category-excel-office"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/eyecatch-OfficeAddins.png","jetpack_shortlink":"https:\/\/wp.me\/p4UZZr-2CJ","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/10089","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10089"}],"version-history":[{"count":1,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/10089\/revisions"}],"predecessor-version":[{"id":10091,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/10089\/revisions\/10091"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/media\/7119"}],"wp:attachment":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10089"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10089"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10089"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}