{"id":10756,"date":"2018-08-24T08:10:35","date_gmt":"2018-08-23T23:10:35","guid":{"rendered":"https:\/\/www.ka-net.org\/blog\/?p=10756"},"modified":"2018-08-24T10:08:19","modified_gmt":"2018-08-24T01:08:19","slug":"%e3%82%a2%e3%82%af%e3%83%86%e3%82%a3%e3%83%96%e3%81%aaie%e3%81%ae%e3%82%bf%e3%83%96%e3%82%92%e9%96%89%e3%81%98%e3%82%8bvba%e3%83%9e%e3%82%af%e3%83%ad","status":"publish","type":"post","link":"https:\/\/www.ka-net.org\/blog\/?p=10756","title":{"rendered":"\u30a2\u30af\u30c6\u30a3\u30d6\u306aIE\u306e\u30bf\u30d6\u3092\u9589\u3058\u308bVBA\u30de\u30af\u30ed"},"content":{"rendered":"<p>\u300c<span style=\"color: #ff0000; font-weight: bold;\">VBA \u30a2\u30af\u30c6\u30a3\u30d6 IE \u30bf\u30d6 \u9589\u3058\u308b<\/span>\u300d\u3068\u3044\u3063\u305f\u30ad\u30fc\u30ef\u30fc\u30c9\u691c\u7d22\u3067\u306e\u30a2\u30af\u30bb\u30b9\u304c\u3042\u308a\u307e\u3057\u305f\u3002<br \/>\n\u30ad\u30fc\u30ef\u30fc\u30c9\u901a\u308a\u3001\u30a2\u30af\u30c6\u30a3\u30d6\u306aInternet Explorer\u306e\u30bf\u30d6\u3092\u30de\u30af\u30ed\u304b\u3089\u9589\u3058\u308b\u51e6\u7406\u3092\u5b9f\u88c5\u3057\u305f\u3044\u65b9\u306b\u3088\u308b\u691c\u7d22\u3060\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u30de\u30af\u30ed\u304c\u3069\u306e\u4f4d\u6709\u7528\u306a\u306e\u304b\u306f\u5206\u304b\u308a\u307e\u305b\u3093\u304c\u3001\u3061\u3087\u3063\u3068\u8208\u5473\u304c\u3042\u3063\u305f\u306e\u3067\u66f8\u3044\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">Public Sub CloseCurrentIeTab1()\r\n'Internet Explorer\u306e\u30a2\u30af\u30c6\u30a3\u30d6\u306a\u30bf\u30d6\u3092\u9589\u3058\u308b\r\n  Dim o As Object\r\n  \r\n  For Each o In GetObject(&quot;new:{9BA05972-F6A8-11CF-A442-00A0C90A8F39}&quot;) 'ShellWindows\r\n    If LCase(TypeName(o)) = &quot;iwebbrowser2&quot; Then\r\n      If LCase(TypeName(o.Document)) = &quot;htmldocument&quot; Then\r\n        'StatusText\u306e\u5909\u66f4\u3067\u30a2\u30af\u30c6\u30a3\u30d6\u306a\u30bf\u30d6\u3092\u5224\u65ad\r\n        'http:\/\/scripting.cocolog-nifty.com\/blog\/2009\/08\/ie7ie8ie-ee95.html \u53c2\u7167\r\n        o.StatusText = &quot;dummy_string&quot;\r\n        If o.StatusText = &quot;dummy_string&quot; Then\r\n          'o.ExecWB 45, 0 'OLECMDID_CLOSE\u3067\u3082\u3044\u3051\u305d\u3046\r\n          o.Document.parentWindow.Open(&quot;about:blank&quot;, &quot;_self&quot;).Close\r\n          Exit For\r\n        End If\r\n      End If\r\n    End If\r\n  Next\r\nEnd Sub<\/pre>\n<p>\u30b3\u30fc\u30c9\u4e2d\u306b\u3082\u66f8\u3044\u3066\u3044\u308b\u901a\u308a\u3001StatusText\u306e\u5909\u66f4\u3067\u30a2\u30af\u30c6\u30a3\u30d6\u306a\u30bf\u30d6\u3092\u5224\u65ad\u3057(\u300c<a href=\"http:\/\/scripting.cocolog-nifty.com\/blog\/2009\/08\/ie7ie8ie-ee95.html\" title=\"IE7\/IE8\u3067\u3001\u73fe\u5728\u307e\u305f\u306f\u6700\u5f8c\u306b\u30a2\u30af\u30c6\u30a3\u30d6\u306aIE\u3092\u6355\u6349\u3059\u308b\u3002: Windows Script Programming\" target=\"_blank\">IE7\/IE8\u3067\u3001\u73fe\u5728\u307e\u305f\u306f\u6700\u5f8c\u306b\u30a2\u30af\u30c6\u30a3\u30d6\u306aIE\u3092\u6355\u6349\u3059\u308b<\/a>\u300d\u53c2\u7167)\u3001\u30bf\u30d6\u3092\u9589\u3058\u308b\u51e6\u7406\u3092\u5b9f\u88c5\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u305f\u3060\u3001\u79c1\u304c\u8a66\u3057\u305f\u3068\u3053\u308d\u3067\u306f\u9023\u7d9a\u3067\u5b9f\u884c\u3059\u308b\u3068\u4e0a\u624b\u304f\u9589\u3058\u3089\u308c\u306a\u3044\u5834\u5408\u304c\u3042\u308a\u3001\u52d5\u4f5c\u304c\u82e5\u5e72\u4e0d\u5b89\u5b9a\u3067\u3057\u305f\u306e\u3067\u3001\u3044\u3064\u3082\u306eUI Automation\u3092\u4f7f\u3063\u305f\u51e6\u7406\u3082\u8003\u3048\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">Public Sub CloseCurrentIeTab2()\r\n'Internet Explorer\u306e\u30a2\u30af\u30c6\u30a3\u30d6\u306a\u30bf\u30d6\u3092\u9589\u3058\u308b\r\n'\u203bUIAutomationClient(UIAutomationCore.dll)\u8981\u53c2\u7167\r\n  Dim ie As Object\r\n  Dim uiAuto As CUIAutomation\r\n  Dim elmIe As IUIAutomationElement\r\n  Dim elmTab As IUIAutomationElement\r\n  Dim elmCloseBtn As IUIAutomationElement\r\n  Dim elmTabs As IUIAutomationElement\r\n  Dim aryTabs As IUIAutomationElementArray\r\n  Dim cnd As IUIAutomationCondition\r\n  Dim iptn As IUIAutomationInvokePattern\r\n  Dim i As Long\r\n  \r\n  Set ie = GetActiveIE\r\n  If ie Is Nothing Then Exit Sub\r\n  Set uiAuto = New CUIAutomation\r\n  Set elmIe = uiAuto.ElementFromHandle(ByVal CLng(ie.Hwnd))\r\n  If elmIe Is Nothing Then Exit Sub\r\n  Set elmTabs = GetElement(uiAuto, _\r\n                           elmIe, _\r\n                           UIA_NamePropertyId, _\r\n                           &quot;\u30bf\u30d6\u884c&quot;, _\r\n                           UIA_TabControlTypeId)\r\n  If elmTabs Is Nothing Then Exit Sub\r\n  Set cnd = uiAuto.CreatePropertyCondition( _\r\n              UIA_ControlTypePropertyId, _\r\n              UIA_TabItemControlTypeId _\r\n            )\r\n  Set aryTabs = elmTabs.FindAll(TreeScope_Subtree, cnd)\r\n  For i = 0 To aryTabs.Length - 1\r\n    Set elmTab = aryTabs.GetElement(i)\r\n    If elmTab.GetCurrentPropertyValue(UIA_SelectionItemIsSelectedPropertyId) Then\r\n      Set elmCloseBtn = GetElement(uiAuto, elmTab, UIA_ControlTypePropertyId, UIA_ButtonControlTypeId)\r\n      If elmCloseBtn Is Nothing Then Exit Sub\r\n      Set iptn = elmCloseBtn.GetCurrentPattern(UIA_InvokePatternId)\r\n      iptn.Invoke\r\n    End If\r\n  Next\r\nEnd Sub\r\n\r\nPrivate Function GetActiveIE() As Object\r\n'\u8d77\u52d5\u4e2d\u306eIE\u53d6\u5f97\r\n  Dim o As Object\r\n   \r\n  For Each o In GetObject(&quot;new:{9BA05972-F6A8-11CF-A442-00A0C90A8F39}&quot;) 'ShellWindows\r\n    If LCase(TypeName(o)) = &quot;iwebbrowser2&quot; Then\r\n      If LCase(TypeName(o.Document)) = &quot;htmldocument&quot; Then\r\n        Set GetActiveIE = o\r\n        Exit For\r\n      End If\r\n    End If\r\n  Next\r\nEnd Function\r\n\r\nPrivate Function GetElement(ByVal uiAuto As CUIAutomation, _\r\n                            ByVal elmParent As IUIAutomationElement, _\r\n                            ByVal propertyId As Long, _\r\n                            ByVal propertyValue As Variant, _\r\n                            Optional ByVal ctrlType As Long = 0) As IUIAutomationElement\r\n  Dim cndFirst As IUIAutomationCondition\r\n  Dim cndSecond As IUIAutomationCondition\r\n    \r\n  Set cndFirst = uiAuto.CreatePropertyCondition( _\r\n                   propertyId, _\r\n                   propertyValue _\r\n                 )\r\n  If ctrlType &lt;&gt; 0 Then\r\n    Set cndSecond = uiAuto.CreatePropertyCondition( _\r\n                      UIA_ControlTypePropertyId, _\r\n                      ctrlType _\r\n                    )\r\n    Set cndFirst = uiAuto.CreateAndCondition( _\r\n                     cndFirst, _\r\n                     cndSecond _\r\n                   )\r\n  End If\r\n  Set GetElement = elmParent.FindFirst(TreeScope_Subtree, cndFirst)\r\nEnd Function<\/pre>\n<p>\u3053\u3061\u3089\u306fInternet Explorer\u306e\u30bf\u30d6\u5217\u3092\u53d6\u5f97\u3057\u305f\u4e0a\u3067\u3001SelectionItem.IsSelected\u30d7\u30ed\u30d1\u30c6\u30a3(UIA_SelectionItemIsSelectedPropertyId)\u304b\u3089\u30a2\u30af\u30c6\u30a3\u30d6\u306a\u30bf\u30d6\u3092\u5224\u65ad\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\n\u30bf\u30d6\u3092\u9589\u3058\u308b\u51e6\u7406\u306f\u3001\u30bf\u30d6\u5185\u306b\u3042\u308b\u9589\u3058\u308b\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u3066\u3044\u308b\u3060\u3051\u3067\u3059\u3002<\/p>\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\u4e0a\u306e\u3088\u3046\u306b2\u30d1\u30bf\u30fc\u30f3\u306e\u51e6\u7406\u3092\u66f8\u3044\u3066\u307f\u307e\u3057\u305f\u3002<br \/>\n\u5b89\u5b9a\u6027\u306e\u4e0a\u3067\u306fUI Automation\u3092\u4f7f\u3063\u305f\u30b3\u30fc\u30c9\u306e\u65b9\u304c\u9ad8\u3044\u306e\u3067\u3059\u304c\u3001\u82e5\u5e72\u30b3\u30fc\u30c9\u304c\u5197\u9577\u306b\u306a\u308a\u307e\u3059\u306e\u3067\u3001\u305d\u3053\u307e\u3067\u7cbe\u5ea6\u3092\u554f\u308f\u306a\u3044\u306e\u3067\u3042\u308c\u3070\u3001\u300cCloseCurrentIeTab1\u300d\u306e\u65b9\u3067\u826f\u3044\u3060\u308d\u3046\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<h4 class=\"style4a\">\u95a2\u9023Web\u30da\u30fc\u30b8<\/h4>\n<div class=\"cardlink\"><a href=\"https:\/\/www.ka-net.org\/blog\/?p=7697\"><div class=\"cardlink_thumbnail\"><img src='https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/eyecatch-OfficeVBA-120x120.png' alt='Internet Explorer\u306e\u30bf\u30d6\u3092\u5207\u308a\u66ff\u3048\u308bVBA\u30de\u30af\u30ed' width=120 height=120 \/><\/a><\/div><div class=\"cardlink_content\"><span class=\"timestamp\">2016.11.18<\/span><div class=\"cardlink_title\"><a href=\"https:\/\/www.ka-net.org\/blog\/?p=7697\">Internet Explorer\u306e\u30bf\u30d6\u3092\u5207\u308a\u66ff\u3048\u308bVBA\u30de\u30af\u30ed <\/a><\/div><div class=\"cardlink_excerpt\">\u524d\u56de\u306e\u8a18\u4e8b\u3067Internet Explorer\u3092\u64cd\u4f5c\u3059\u308bVBA\u30de\u30af\u30ed\u3092\u7d39\u4ecb\u3057\u307e\u3057\u305f\u304c\u3001\u3064\u3044\u3067\u306bURL\u3092\u6307\u5b9a\u3057\u3066\u3001Internet Explorer\u306e\u30bf\u30d6\u3092\u5207\u308a\u66ff\u3048\u308b\u30de\u30af\u30ed\u3082\u66f8\u3044\u3066\u307f\u307e\u3057\u305f\u3002\r\n\r\n\u203b 64\u30d3\u30c3\u30c8\u7248Office\u3067\u306f\u30b3\u30fc\u30c9\u3092\u66f8\u304d\u304b\u3048\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059...<\/div><\/div><div class=\"cardlink_footer\"><\/div><\/div>\n","protected":false},"excerpt":{"rendered":"\u300cVBA \u30a2\u30af\u30c6\u30a3\u30d6 IE \u30bf\u30d6 \u9589\u3058\u308b\u300d\u3068\u3044\u3063\u305f\u30ad\u30fc\u30ef\u30fc\u30c9\u691c\u7d22\u3067\u306e\u30a2\u30af\u30bb\u30b9\u304c\u3042\u308a\u307e\u3057\u305f\u3002 \u30ad\u30fc\u30ef\u30fc\u30c9\u901a\u308a\u3001\u30a2\u30af\u30c6\u30a3\u30d6\u306aInternet Explorer\u306e\u30bf\u30d6\u3092\u30de\u30af\u30ed\u304b\u3089\u9589\u3058\u308b\u51e6\u7406\u3092\u5b9f\u88c5\u3057\u305f\u3044\u65b9\u306b\u3088\u308b\u691c\u7d22\u3060\u3068\u601d\u3044\u307e\u3059\u3002 [&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":"[\u30a2\u30af\u30c6\u30a3\u30d6\u306aIE\u306e\u30bf\u30d6\u3092\u9589\u3058\u308bVBA\u30de\u30af\u30ed]","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-10756","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-2Nu","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/10756","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=10756"}],"version-history":[{"count":3,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/10756\/revisions"}],"predecessor-version":[{"id":10759,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/10756\/revisions\/10759"}],"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=10756"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10756"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10756"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}