{"id":9385,"date":"2017-12-20T10:42:20","date_gmt":"2017-12-20T01:42:20","guid":{"rendered":"https:\/\/www.ka-net.org\/blog\/?p=9385"},"modified":"2017-12-20T10:42:20","modified_gmt":"2017-12-20T01:42:20","slug":"office-%e3%82%af%e3%83%aa%e3%83%83%e3%83%97%e3%83%9c%e3%83%bc%e3%83%89%e3%82%92%e3%83%9e%e3%82%af%e3%83%ad%e3%81%a7%e6%93%8d%e4%bd%9c%e3%81%99%e3%82%8bmsaa","status":"publish","type":"post","link":"https:\/\/www.ka-net.org\/blog\/?p=9385","title":{"rendered":"Office \u30af\u30ea\u30c3\u30d7\u30dc\u30fc\u30c9\u3092\u30de\u30af\u30ed\u3067\u64cd\u4f5c\u3059\u308b(MSAA)"},"content":{"rendered":"<p><a href=\"https:\/\/social.msdn.microsoft.com\/Forums\/ja-JP\/vbajp\/thread\/42f330fa-4a3d-4031-bbba-460273afccc7\" title=\"Excel2013\u3000VBA\u3000Office\u30af\u30ea\u30c3\u30d7\u30dc\u30fc\u30c9\u3000\u3059\u3079\u3066\u30af\u30ea\u30a2\u3059\u308b\u65b9\u6cd5\u3092\u6559\u3048\u3066\u304f\u3060\u3055\u3044\" target=\"_blank\">MSDN\u30d5\u30a9\u30fc\u30e9\u30e0\u306b\u8cea\u554f<\/a>\u304c\u3042\u308a\u307e\u3057\u305f\u304c\u3001Office \u30af\u30ea\u30c3\u30d7\u30dc\u30fc\u30c9\u3092\u30de\u30af\u30ed\u3067\u64cd\u4f5c\u3059\u308b\u306e\u306f\u4e00\u5b9a\u306e\u9700\u8981\u304c\u3042\u308b\u306e\u3067\u3001\u4ee5\u524d\u66f8\u3044\u305f\u30de\u30af\u30ed(\u4e0b\u8a18\u53c2\u7167)\u3092\u66f8\u304d\u76f4\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<ul>\n<li>Office \u30af\u30ea\u30c3\u30d7\u30dc\u30fc\u30c9\u3092\u30de\u30af\u30ed\u3067\u64cd\u4f5c\u3059\u308b(Office 2003)<\/li>\n<li style=\"list-style-type:none;\"><a href=\"http:\/\/www.ka-net.org\/office\/of55.html\" target=\"_blank\" title=\"Office \u30af\u30ea\u30c3\u30d7\u30dc\u30fc\u30c9\u3092\u30de\u30af\u30ed\u3067\u64cd\u4f5c\u3059\u308b(Office 2003)\">http:\/\/www.ka-net.org\/office\/of55.html<\/a><\/li>\n<li>Office \u30af\u30ea\u30c3\u30d7\u30dc\u30fc\u30c9\u3092\u30de\u30af\u30ed\u3067\u64cd\u4f5c\u3059\u308b(Office 2007\u4ee5\u964d)<\/li>\n<li style=\"list-style-type:none;\"><a href=\"http:\/\/www.ka-net.org\/office\/of56.html\" target=\"_blank\" title=\"Office \u30af\u30ea\u30c3\u30d7\u30dc\u30fc\u30c9\u3092\u30de\u30af\u30ed\u3067\u64cd\u4f5c\u3059\u308b(Office 2007\u4ee5\u964d)\">http:\/\/www.ka-net.org\/office\/of56.html<\/a><\/li>\n<\/ul>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">Option Explicit\r\n\r\nPrivate Declare Function AccessibleChildren Lib &quot;oleacc&quot; ( _\r\n  ByVal paccContainer As IAccessible, _\r\n  ByVal iChildStart As Long, _\r\n  ByVal cChildren As Long, _\r\n  ByRef rgvarChildren As Any, _\r\n  ByRef pcObtained As Long) As Long\r\n\r\nPublic Sub Sample()\r\n  'DoActionOfficeClipboard &quot;\u3059\u3079\u3066\u8cbc\u308a\u4ed8\u3051&quot;\r\n  DoActionOfficeClipboard &quot;\u3059\u3079\u3066\u30af\u30ea\u30a2&quot;\r\nEnd Sub\r\n\r\nPrivate Sub DoActionOfficeClipboard(ByVal ButtonName As String)\r\n'Office\u30af\u30ea\u30c3\u30d7\u30dc\u30fc\u30c9\u30b3\u30de\u30f3\u30c9\u5b9f\u884c\r\n  Dim accClipboard As IAccessible\r\n  Dim accCollectPage As IAccessible\r\n  Dim accButton As IAccessible\r\n  Dim tmp As Boolean\r\n  Dim i As Long\r\n  Const CommandBarName = &quot;Office Clipboard&quot;\r\n  Const ROLE_SYSTEM_PROPERTYPAGE = &amp;H26\r\n  Const ROLE_SYSTEM_PUSHBUTTON = &amp;H2B\r\n  Const CHILDID_SELF = &amp;H0&amp;\r\n  \r\n  Select Case ButtonName\r\n    Case &quot;\u3059\u3079\u3066\u8cbc\u308a\u4ed8\u3051&quot;, &quot;\u3059\u3079\u3066\u30af\u30ea\u30a2&quot;\r\n    Case Else\r\n      MsgBox &quot;\u6307\u5b9a\u3057\u305f\u30b3\u30de\u30f3\u30c9\u306b\u306f\u5bfe\u5fdc\u3057\u3066\u3044\u307e\u305b\u3093\u3002&quot; &amp; vbNewLine &amp; _\r\n             &quot;\u300c\u3059\u3079\u3066\u8cbc\u308a\u4ed8\u3051\u300d\u304b\u300c\u3059\u3079\u3066\u30af\u30ea\u30a2\u300d\u306e\u3069\u3061\u3089\u304b\u3092\u6307\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044\u3002&quot;, _\r\n             vbCritical + vbSystemModal\r\n      Exit Sub\r\n  End Select\r\n  \r\n  With Application.CommandBars(CommandBarName)\r\n    tmp = .Visible\r\n    .Visible = True\r\n  End With\r\n  DoEvents\r\n  Set accClipboard = Application.CommandBars(CommandBarName)\r\n  If accClipboard Is Nothing Then GoTo Fin\r\n  \r\n  '\u65e7\u30d0\u30fc\u30b8\u30e7\u30f3Office\u5bfe\u5fdc\r\n  Set accCollectPage = GetAccessibleObject(accClipboard, _\r\n                                           &quot;Collect and Paste 2.0&quot;, _\r\n                                           ROLE_SYSTEM_PROPERTYPAGE)\r\n  If Not accCollectPage Is Nothing Then\r\n    For i = 1 To accCollectPage.accChildCount\r\n      If (accCollectPage.accName(i&amp;) = ButtonName) And _\r\n         (accCollectPage.accRole(i&amp;) = ROLE_SYSTEM_PUSHBUTTON) Then\r\n        accCollectPage.accDoDefaultAction i&amp;\r\n        Exit For\r\n      End If\r\n    Next\r\n  Else\r\n    '\u65b0\u30d0\u30fc\u30b8\u30e7\u30f3Office\u5bfe\u5fdc\r\n    Set accCollectPage = GetAccessibleObject(accClipboard, _\r\n                                           &quot;\u30af\u30ea\u30c3\u30d7\u30dc\u30fc\u30c9&quot;, _\r\n                                           ROLE_SYSTEM_PROPERTYPAGE)\r\n    If Not accCollectPage Is Nothing Then\r\n      Set accButton = GetAccessibleObject(accCollectPage, _\r\n                                          ButtonName, _\r\n                                          ROLE_SYSTEM_PUSHBUTTON)\r\n      If accButton Is Nothing Then GoTo Fin\r\n      accButton.accDoDefaultAction CHILDID_SELF\r\n    Else\r\n      MsgBox &quot;\u30af\u30ea\u30c3\u30d7\u30dc\u30fc\u30c9\u30a6\u30a3\u30f3\u30c9\u30a6\u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093\u3067\u3057\u305f\u3002&quot; &amp; vbNewLine &amp; _\r\n             &quot;\u51e6\u7406\u3092\u4e2d\u6b62\u3057\u307e\u3059\uff61 &quot;, vbCritical + vbSystemModal\r\n    End If\r\n  End If\r\nFin:\r\n  Application.CommandBars(CommandBarName).Visible = tmp\r\nEnd Sub\r\n\r\nPrivate Function GetAccessibleObject(ByVal SrcAccObj As IAccessible, _\r\n                                     ByVal TgtAccName As String, _\r\n                                     ByVal TgtAccRole As Long) As IAccessible\r\n  Dim ret As IAccessible\r\n  Dim list() As Variant\r\n  Dim cnt As Long, i As Long\r\n  Const CHILDID_SELF = &amp;H0&amp;\r\n  \r\n  Set ret = Nothing '\u521d\u671f\u5316\r\n  If (SrcAccObj.accName(CHILDID_SELF) = TgtAccName) And _\r\n     (SrcAccObj.accRole(CHILDID_SELF) = TgtAccRole) Then\r\n    Set ret = SrcAccObj\r\n  Else\r\n    cnt = SrcAccObj.accChildCount\r\n    If cnt &gt; 0 Then\r\n      ReDim list(cnt - 1)\r\n      If AccessibleChildren(SrcAccObj, 0, cnt, list(0), cnt) = 0 Then\r\n        For i = LBound(list) To UBound(list)\r\n          If TypeOf list(i) Is IAccessible Then\r\n            Set ret = GetAccessibleObject(list(i), TgtAccName, TgtAccRole)\r\n            If Not ret Is Nothing Then Exit For\r\n          End If\r\n        Next\r\n      End If\r\n    End If\r\n  End If\r\n  Set GetAccessibleObject = ret\r\nEnd Function<\/pre>\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<p>\u4ee5\u524d\u66f8\u3044\u305f\u30b3\u30fc\u30c9\u306f\u3001Office\u3084OS\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u304c\u5909\u308f\u308b\u3068\u52d5\u4f5c\u3057\u307e\u305b\u3093\u3067\u3057\u305f\u304c\u3001\u4eca\u56de\u306f\u30d0\u30fc\u30b8\u30e7\u30f3\u306e\u5dee\u7570\u3082\u4e00\u5fdc\u8003\u616e\u3057\u3066\u3044\u307e\u3059(Excel 2007,2010,2016\u3067\u78ba\u8a8d)\u3002<\/p>\n<p>\u3068\u306f\u3044\u3048\u3001\u6b21\u671f\u30d0\u30fc\u30b8\u30e7\u30f3\u3067\u52d5\u4f5c\u3059\u308b\u304b\u306f\u5206\u304b\u308a\u307e\u305b\u3093\u3057\u3001Office \u30af\u30ea\u30c3\u30d7\u30dc\u30fc\u30c9\u3092\u64cd\u4f5c\u3059\u308b\u305f\u3081\u3060\u3051\u306b\u51e6\u7406\u3092\u8907\u96d1\u306b\u3059\u308b\u306e\u3082\u554f\u984c\u3067\u3059\u306e\u3067\u3001\u3053\u306e\u6a5f\u80fd\u304c\u3069\u3046\u3057\u3066\u3082\u5fc5\u8981\u3067\u306a\u3044\u5834\u5408\u306f\u3001\u5b9f\u88c5\u3057\u306a\u3044\u65b9\u5411\u3067\u8abf\u6574\u3057\u3066\u3082\u826f\u3044\u306e\u3067\u306f\u306a\u3044\u304b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<h4 class=\"style4a\">\u95a2\u9023\u8a18\u4e8b<\/h4>\n<div class=\"cardlink\"><a href=\"https:\/\/www.ka-net.org\/blog\/?p=4944\"><div class=\"cardlink_thumbnail\"><img src='https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/eyecatch-Excel-120x120.png' alt='Office \u30af\u30ea\u30c3\u30d7\u30dc\u30fc\u30c9\u3092\u30de\u30af\u30ed\u3067\u64cd\u4f5c\u3059\u308b(UI Automation)' width=120 height=120 \/><\/a><\/div><div class=\"cardlink_content\"><span class=\"timestamp\">2014.10.16<\/span><div class=\"cardlink_title\"><a href=\"https:\/\/www.ka-net.org\/blog\/?p=4944\">Office \u30af\u30ea\u30c3\u30d7\u30dc\u30fc\u30c9\u3092\u30de\u30af\u30ed\u3067\u64cd\u4f5c\u3059\u308b(UI Automation) <\/a><\/div><div class=\"cardlink_excerpt\">\u4ee5\u524dMSAA\u3092\u5229\u7528\u3057\u3066Office \u30af\u30ea\u30c3\u30d7\u30dc\u30fc\u30c9\u3092\u64cd\u4f5c\u3059\u308b\u30de\u30af\u30ed\u3092\u66f8\u3044\u305f\u3053\u3068\u304c\u3042\u308b\u306e\u3067\u3059\u304c\u3001\r\n\r\n\r\n\u30fbOffice 2007\/2010\u30fb\u30ea\u30dc\u30f3\u306e\u30ab\u30b9\u30bf\u30de\u30a4\u30ba \u521d\u5fc3\u8005\u5099\u5fd8\u9332\r\n\/\/www.ka-net.org\/office\/of55.html\r\n\u30fbOffi...<\/div><\/div><div class=\"cardlink_footer\"><\/div><\/div>\n","protected":false},"excerpt":{"rendered":"MSDN\u30d5\u30a9\u30fc\u30e9\u30e0\u306b\u8cea\u554f\u304c\u3042\u308a\u307e\u3057\u305f\u304c\u3001Office \u30af\u30ea\u30c3\u30d7\u30dc\u30fc\u30c9\u3092\u30de\u30af\u30ed\u3067\u64cd\u4f5c\u3059\u308b\u306e\u306f\u4e00\u5b9a\u306e\u9700\u8981\u304c\u3042\u308b\u306e\u3067\u3001\u4ee5\u524d\u66f8\u3044\u305f\u30de\u30af\u30ed(\u4e0b\u8a18\u53c2\u7167)\u3092\u66f8\u304d\u76f4\u3057\u3066\u307f\u307e\u3057\u305f\u3002 Office \u30af\u30ea\u30c3\u30d7\u30dc\u30fc\u30c9\u3092\u30de\u30af\u30ed\u3067\u64cd\u4f5c\u3059\u308b(Offi [&hellip;]","protected":false},"author":1,"featured_media":7120,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"\u4ee5\u524d\u66f8\u3044\u305f\u30b3\u30fc\u30c9\u3092\u4e00\u90e8\u66f8\u304d\u76f4\u3057\u307e\u3057\u305f\u3002 [Office \u30af\u30ea\u30c3\u30d7\u30dc\u30fc\u30c9\u3092\u30de\u30af\u30ed\u3067\u64cd\u4f5c\u3059\u308b(MSAA)]","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":[4,48,49,58],"tags":[],"class_list":["post-9385","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-office","category-excel-office","category-word-office","category-powerpoint"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/eyecatch-OfficeVBA.png","jetpack_shortlink":"https:\/\/wp.me\/p4UZZr-2rn","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/9385","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=9385"}],"version-history":[{"count":1,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/9385\/revisions"}],"predecessor-version":[{"id":9386,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/9385\/revisions\/9386"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/media\/7120"}],"wp:attachment":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=9385"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=9385"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=9385"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}