{"id":4624,"date":"2014-07-16T13:18:56","date_gmt":"2014-07-16T04:18:56","guid":{"rendered":"http:\/\/www.ka-net.org\/blog\/?p=4624"},"modified":"2014-07-16T13:18:56","modified_gmt":"2014-07-16T04:18:56","slug":"%e3%83%aa%e3%83%9c%e3%83%b3%e3%81%ae%e3%82%bf%e3%83%96%e3%82%92%e9%81%b8%e6%8a%9e%e3%81%99%e3%82%8bvba%e3%83%9e%e3%82%af%e3%83%ad","status":"publish","type":"post","link":"https:\/\/www.ka-net.org\/blog\/?p=4624","title":{"rendered":"\u30ea\u30dc\u30f3\u306e\u30bf\u30d6\u3092\u9078\u629e\u3059\u308bVBA\u30de\u30af\u30ed"},"content":{"rendered":"<p>\u30de\u30af\u30ed\u3067\u30ea\u30dc\u30f3\u306e\u30bf\u30d6\u3092\u9078\u629e\u3059\u308b\u65b9\u6cd5\u3068\u3057\u3066\u3001<a href=\"\/\/www.ka-net.org\/ribbon\/ri33.html\" title=\"\u30ea\u30dc\u30f3\u306e\u30bf\u30d6\u3092\u52d5\u7684\u306b\u5207\u308a\u66ff\u3048\u308b(Office 2010)\" target=\"_blank\">ActivateTab\u3084ActivateTabMso\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3046\u65b9\u6cd5<\/a>\u3084<a href=\"\/\/www.ka-net.org\/ribbon\/ri14.html\" title=\"\u30ea\u30dc\u30f3\u306e\u30bf\u30d6\u3092\u52d5\u7684\u306b\u5207\u308a\u66ff\u3048\u308b\" target=\"_blank\">MSAA\u3092\u4f7f\u3046\u65b9\u6cd5<\/a>\u304c\u3042\u308a\u307e\u3059\u304c\u3001\u4eca\u56de\u306fUI Automation\u3067\u30bf\u30d6\u3092\u9078\u629e\u3059\u308b\u30de\u30af\u30ed\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<p><span style=\"color: #ff0000; font-weight: bold;\">\u203b UIAutomationClient(UIAutomationCore.dll)\u8981\u53c2\u7167<\/span><br \/>\n<span style=\"color: #ff0000; font-weight: bold;\">\u203b UIAutomationClient\u53c2\u7167\u6642\u306b\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3059\u308b\u5834\u5408\u306f\u300c<a href=\"\/\/www.ka-net.org\/blog\/?p=4617\" title=\"UIAutomationClient\u53c2\u7167\u6642\u306bDLL\u8aad\u307f\u8fbc\u307f\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u305f\u6642\u306e\u5bfe\u51e6\u6cd5\" target=\"_blank\">UIAutomationClient\u53c2\u7167\u6642\u306bDLL\u8aad\u307f\u8fbc\u307f\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u305f\u6642\u306e\u5bfe\u51e6\u6cd5<\/a>\u300d\u53c2\u7167<\/span><\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">Option Explicit\r\n\r\nPublic Sub Sample()\r\n  MsgBox &quot;&#x5B;\u30db\u30fc\u30e0]\u30bf\u30d6\u3092\u9078\u629e\u3057\u307e\u3059\u3002&quot;, vbSystemModal\r\n  SelectRibbonTab &quot;\u30db\u30fc\u30e0&quot;\r\n  MsgBox &quot;&#x5B;\u30d5\u30a1\u30a4\u30eb]\u30bf\u30d6\u3092\u9078\u629e\u3057\u307e\u3059\u3002&quot;, vbSystemModal\r\n  SelectRibbonTab &quot;\u30d5\u30a1\u30a4\u30eb \u30bf\u30d6&quot;\r\nEnd Sub\r\n\r\nPublic Sub SelectRibbonTab(ByVal TabName As String)\r\n'\u30ea\u30dc\u30f3\u306e\u30bf\u30d6\u3092\u9078\u629e\r\n  Dim uiAuto As UIAutomationClient.CUIAutomation\r\n  Dim elmRibbon As UIAutomationClient.IUIAutomationElement\r\n  Dim elmRibbonTab As UIAutomationClient.IUIAutomationElement\r\n  Dim cndProperty As UIAutomationClient.IUIAutomationCondition\r\n  Dim aryRibbonTab As UIAutomationClient.IUIAutomationElementArray\r\n  Dim ptnAcc As UIAutomationClient.IUIAutomationLegacyIAccessiblePattern\r\n  Dim accRibbon As Office.IAccessible\r\n  Dim i As Long\r\n  \r\n  Set elmRibbonTab = Nothing '\u521d\u671f\u5316\r\n  Set uiAuto = New UIAutomationClient.CUIAutomation\r\n  Set accRibbon = Application.CommandBars(&quot;Ribbon&quot;)\r\n  Set elmRibbon = uiAuto.ElementFromIAccessible(accRibbon, 0)\r\n  Set cndProperty = uiAuto.CreatePropertyCondition(UIA_ClassNamePropertyId, &quot;NetUIRibbonTab&quot;)\r\n  Set aryRibbonTab = elmRibbon.FindAll(TreeScope_Subtree, cndProperty)\r\n  For i = 0 To aryRibbonTab.Length - 1\r\n    If aryRibbonTab.GetElement(i).CurrentName = TabName Then\r\n      Set elmRibbonTab = aryRibbonTab.GetElement(i)\r\n      Exit For\r\n    End If\r\n  Next\r\n  If elmRibbonTab Is Nothing Then Exit Sub\r\n  Set ptnAcc = elmRibbonTab.GetCurrentPattern(UIA_LegacyIAccessiblePatternId)\r\n  ptnAcc.DoDefaultAction\r\nEnd Sub<\/pre>\n<p>Microsoft Community\u306b\u3042\u3063\u305f\u8cea\u554f\u300c<a href=\"http:\/\/answers.microsoft.com\/thread\/9ba27093-b423-4fe4-92ba-9b33745fc2c0\" title=\"\u3010PowerPoint\u3000VBA\u3011\u3000\u30b0\u30e9\u30d5\u5185\u306e\u30c7\u30fc\u30bf\u30e9\u30d9\u30eb\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u53d6\u5f97\u3059\u308b\u30b3\u30fc\u30c9\" target=\"_blank\">\u3010PowerPoint\u3000VBA\u3011\u3000\u30b0\u30e9\u30d5\u5185\u306e\u30c7\u30fc\u30bf\u30e9\u30d9\u30eb\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u53d6\u5f97\u3059\u308b\u30b3\u30fc\u30c9<\/a>\u300d\u306e\u56de\u7b54\u7528\u306b\u66f8\u3044\u305f\u30b3\u30fc\u30c9\u306e\u4e00\u90e8\u629c\u7c8b\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\nMSAA\u3067\u306e\u51e6\u7406\u3068\u6bd4\u3079\u308b\u3068\u5927\u5206\u3059\u3063\u304d\u308a\u3057\u3066\u3044\u3066\u826f\u3044\u611f\u3058\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u30de\u30af\u30ed\u3067\u30ea\u30dc\u30f3\u306e\u30bf\u30d6\u3092\u9078\u629e\u3059\u308b\u65b9\u6cd5\u3068\u3057\u3066\u3001ActivateTab\u3084ActivateTabMso\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3046\u65b9\u6cd5\u3084MSAA\u3092\u4f7f\u3046\u65b9\u6cd5\u304c\u3042\u308a\u307e\u3059\u304c\u3001\u4eca\u56de\u306fUI Automation\u3067\u30bf\u30d6\u3092\u9078\u629e\u3059\u308b\u30de\u30af\u30ed\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002 \u203b  [&hellip;]","protected":false},"author":1,"featured_media":7130,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[48,4,49,1],"tags":[],"class_list":["post-4624","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-excel-office","category-office","category-word-office","category-ribbon"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/eyecatch-Ribbon.png","jetpack_shortlink":"https:\/\/wp.me\/p4UZZr-1cA","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4624","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=4624"}],"version-history":[{"count":3,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4624\/revisions"}],"predecessor-version":[{"id":4627,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4624\/revisions\/4627"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/media\/7130"}],"wp:attachment":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4624"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4624"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4624"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}