{"id":7697,"date":"2016-11-18T14:44:58","date_gmt":"2016-11-18T05:44:58","guid":{"rendered":"https:\/\/www.ka-net.org\/blog\/?p=7697"},"modified":"2016-11-18T14:44:58","modified_gmt":"2016-11-18T05:44:58","slug":"internet-explorer%e3%81%ae%e3%82%bf%e3%83%96%e3%82%92%e5%88%87%e3%82%8a%e6%9b%bf%e3%81%88%e3%82%8bvba%e3%83%9e%e3%82%af%e3%83%ad","status":"publish","type":"post","link":"https:\/\/www.ka-net.org\/blog\/?p=7697","title":{"rendered":"Internet Explorer\u306e\u30bf\u30d6\u3092\u5207\u308a\u66ff\u3048\u308bVBA\u30de\u30af\u30ed"},"content":{"rendered":"<p><a href=\"https:\/\/www.ka-net.org\/blog\/?p=7694\" title=\"Google\u7ffb\u8a33\u3067\u6587\u5b57\u5217\u3092\u7ffb\u8a33\u3059\u308bVBA\u30de\u30af\u30ed(IE\u64cd\u4f5c\u7248) | \u521d\u5fc3\u8005\u5099\u5fd8\u9332\" target=\"_blank\">\u524d\u56de\u306e\u8a18\u4e8b<\/a>\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<\/p>\n<p><span style=\"color: #ff0000; font-weight: bold;\">\u203b 64\u30d3\u30c3\u30c8\u7248Office\u3067\u306f\u30b3\u30fc\u30c9\u3092\u66f8\u304d\u304b\u3048\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/span><\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">'UIAutomationClient(UIAutomationCore.dll)\u8981\u53c2\u7167\r\nOption Explicit\r\n\r\nPrivate Declare Function FindWindowEx Lib &quot;User32&quot; Alias &quot;FindWindowExA&quot; ( _\r\n  ByVal hWndParent As Long, _\r\n  ByVal hWndChildAfter As Long, _\r\n  ByVal lpszClass As String, _\r\n  ByVal lpszWindow As String) As Long\r\nPrivate Declare Function ShowWindow Lib &quot;User32&quot; ( _\r\n  ByVal hWnd As Long, _\r\n  ByVal nCmdShow As Long) As Long\r\nPrivate Const SW_SHOWNORMAL = 1\r\n\r\nPublic Sub Sample()\r\n  SelectIETab &quot;weather.yahoo.co.jp&quot;\r\nEnd Sub\r\n\r\nPrivate Sub SelectIETab(ByVal url As String)\r\n'\u6307\u5b9a\u3057\u305fURL\u306e\u30bf\u30d6\u306b\u5207\u308a\u66ff\u3048\u308b\r\n  Dim ie As Object\r\n  Dim uiAuto As CUIAutomation\r\n  Dim elmNavBar As IUIAutomationElement\r\n  Dim elmTabs As IUIAutomationElement\r\n  Dim aryTabs As IUIAutomationElementArray\r\n  Dim ptnSelectionItem As IUIAutomationSelectionItemPattern\r\n  Dim cnd As IUIAutomationCondition\r\n  Dim hNavBar As Long, i As Long\r\n  \r\n  Set ie = GetActiveIE(url)\r\n  If ie Is Nothing Then Exit Sub\r\n  ShowWindow ie.hWnd, SW_SHOWNORMAL '\u6700\u5c11\u5316\u6642\u3092\u8003\u616e\u3057\u3066\u30a6\u30a3\u30f3\u30c9\u30a6\u3092\u5143\u306b\u623b\u3059\r\n  hNavBar = FindWindowEx(ie.hWnd, 0, &quot;WorkerW&quot;, vbNullString) '\u30ca\u30d3\u30b2\u30fc\u30b7\u30e7\u30f3 \u30d0\u30fc\r\n  If hNavBar = 0 Then Exit Sub\r\n  Set uiAuto = New CUIAutomation\r\n  Set elmNavBar = uiAuto.ElementFromHandle(ByVal hNavBar)\r\n  If elmNavBar Is Nothing Then Exit Sub\r\n  Set elmTabs = GetElement(uiAuto, _\r\n                           elmNavBar, _\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    'LegacyIAccessible.Description\u306bURL\u304c\u542b\u307e\u308c\u3066\u3044\u308b\u304b\u3092\u5224\u65ad\u3057\u3066\u30bf\u30d6\u9078\u629e\r\n    If InStr(aryTabs.GetElement(i).GetCurrentPropertyValue(UIA_LegacyIAccessibleDescriptionPropertyId), _\r\n             ie.LocationURL) Then\r\n      Set ptnSelectionItem = aryTabs.GetElement(i).GetCurrentPattern(UIA_SelectionItemPatternId)\r\n      ptnSelectionItem.Select\r\n      Exit For\r\n    End If\r\n  Next\r\nEnd Sub\r\n\r\nPrivate Function GetActiveIE(ByVal url As String) As Object\r\n'URL\u3092\u6307\u5b9a\u3057\u3066\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        If o.LocationURL Like &quot;*&quot; &amp; url &amp; &quot;*&quot; Then\r\n          Set GetActiveIE = o\r\n          Exit For\r\n        End If\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><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/SelectIETab_01.gif\" alt=\"selectietab_01\" width=\"598\" height=\"479\" class=\"alignnone size-full wp-image-7698\" \/><\/p>\n<p>\u4e0a\u56f3\u306e\u901a\u308a\u3001Windows 10 + Internet Explorer 11\u74b0\u5883\u3067\u3082\u52d5\u4f5c\u3057\u307e\u3057\u305f\u304c\u3001\u3042\u307e\u308a\u51fa\u756a\u306f\u306a\u3055\u305d\u3046\u306a\u30de\u30af\u30ed\u3067\u3059\u3002<\/p>\n<h4 class=\"style4a\">\u95a2\u9023Web\u30da\u30fc\u30b8<\/h4>\n<ul>\n<li>IE7\u3067\u7279\u5b9a\u30bf\u30d6\u3092\u30a2\u30af\u30c6\u30a3\u30d6\u306b\u3057\u305f\u3044<\/li>\n<li style=\"list-style-type:none;\"><a href=\"https:\/\/social.msdn.microsoft.com\/Forums\/ja-JP\/vbgeneralja\/thread\/f99d5464-8096-4501-88a6-d3d016aa976d\" target=\"_blank\" title=\"IE7\u3067\u7279\u5b9a\u30bf\u30d6\u3092\u30a2\u30af\u30c6\u30a3\u30d6\u306b\u3057\u305f\u3044\">https:\/\/social.msdn.microsoft.com\/Forums\/ja-JP\/vbgeneralja\/thread\/f99d5464-8096-4501-88a6-d3d016aa976d<\/a><\/li>\n<li>IE7 Tabs<\/li>\n<li style=\"list-style-type:none;\"><a href=\"https:\/\/social.msdn.microsoft.com\/Forums\/en-US\/ieextensiondevelopment\/thread\/6c926f83-3eca-47ef-882f-c7f8816b9000\" target=\"_blank\" title=\"IE7 Tabs\">https:\/\/social.msdn.microsoft.com\/Forums\/en-US\/ieextensiondevelopment\/thread\/6c926f83-3eca-47ef-882f-c7f8816b9000<\/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":"\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 \u203b 64\u30d3\u30c3\u30c8\u7248Office\u3067 [&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":"\u3042\u307e\u308a\u51fa\u756a\u306f\u306a\u3055\u305d\u3046\u306a\u30de\u30af\u30ed\u3067\u3059\u3002 [Internet Explorer\u306e\u30bf\u30d6\u3092\u5207\u308a\u66ff\u3048\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-7697","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-209","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/7697","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=7697"}],"version-history":[{"count":1,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/7697\/revisions"}],"predecessor-version":[{"id":7699,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/7697\/revisions\/7699"}],"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=7697"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7697"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7697"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}