{"id":7928,"date":"2017-02-01T15:40:20","date_gmt":"2017-02-01T06:40:20","guid":{"rendered":"https:\/\/www.ka-net.org\/blog\/?p=7928"},"modified":"2017-02-01T15:40:20","modified_gmt":"2017-02-01T06:40:20","slug":"%e3%80%902017%e5%b9%b41%e6%9c%88%e7%89%88%e3%80%91microsoft-edge%e3%82%92%e6%93%8d%e4%bd%9c%e3%81%99%e3%82%8bvba%e3%83%9e%e3%82%af%e3%83%addom%e7%b7%a82","status":"publish","type":"post","link":"https:\/\/www.ka-net.org\/blog\/?p=7928","title":{"rendered":"\u30102017\u5e741\u6708\u7248\u3011Microsoft Edge\u3092\u64cd\u4f5c\u3059\u308bVBA\u30de\u30af\u30ed(DOM\u7de8)(2)"},"content":{"rendered":"<p><a href=\"https:\/\/www.ka-net.org\/blog\/?p=7921\" title=\"\u30102017\u5e741\u6708\u7248\u3011Microsoft Edge\u3092\u64cd\u4f5c\u3059\u308bVBA\u30de\u30af\u30ed(DOM\u7de8) | \u521d\u5fc3\u8005\u5099\u5fd8\u9332\" target=\"_blank\">\u6628\u65e5\u306e\u8a18\u4e8b<\/a>\u3067\u3001Microsoft Edge\u3092\u64cd\u4f5c\u3059\u308bVBA\u30b3\u30fc\u30c9\u3092\u6539\u3081\u3066\u66f8\u304d\u307e\u3057\u305f\u304c\u3001\u6628\u65e5\u306e\u30b3\u30fc\u30c9\u306f\u300c<span style=\"color: #ff0000; font-weight: bold;\">TabWindowClass<\/span>\u300d\u30af\u30e9\u30b9\u306e\u30a6\u30a3\u30f3\u30c9\u30a6\u3092\u6c7a\u3081\u6253\u3061\u3057\u3066\u3044\u308b\u306e\u3067\u3001Edge\u306e\u4ed5\u69d8\u5909\u66f4\u306b\u3088\u308a\u52d5\u4f5c\u3057\u306a\u304f\u306a\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\n(VBA\u3067Edge\u3092\u64cd\u4f5c\u3059\u308b\u306e\u3092\u6b62\u3081\u308c\u3070\u826f\u3044\u3060\u3051\u306a\u3093\u3067\u3059\u304c\u30fb\u30fb\u30fb)<\/p>\n<p>\u305d\u3053\u3067\u4eca\u56de\u306f\u3084\u308a\u65b9\u3092\u5909\u3048\u3066\u3001\u8d77\u52d5\u4e2d\u306e\u30d7\u30ed\u30bb\u30b9\u304b\u3089Edge\u3092\u63a2\u3057\u3001\u305d\u306e\u5b50\u30a6\u30a3\u30f3\u30c9\u30a6\u306e\u4e2d\u304b\u3089\u300c<span style=\"color: #ff0000; font-weight: bold;\">Internet Explorer_Server<\/span>\u300d\u30af\u30e9\u30b9\u306e\u30a6\u30a3\u30f3\u30c9\u30a6\u3092\u53d6\u5f97\u3059\u308b\u65b9\u6cd5\u3092\u8003\u3048\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">'\u6a19\u6e96\u30e2\u30b8\u30e5\u30fc\u30eb\r\nOption Explicit\r\n \r\nPrivate Declare Function EnumChildWindows Lib &quot;user32&quot; (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, lParam As Long) As Long\r\nPrivate Declare Function GetClassName Lib &quot;user32&quot; Alias &quot;GetClassNameA&quot; (ByVal hWnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long\r\nPrivate Declare Function GetNextWindow Lib &quot;user32&quot; Alias &quot;GetWindow&quot; (ByVal hWnd As Long, ByVal wFlag As Long) As Long\r\nPrivate Declare Function GetParent Lib &quot;user32&quot; (ByVal hWnd As Long) As Long\r\nPrivate Declare Function GetTopWindow Lib &quot;user32&quot; (ByVal hWnd As Long) As Long\r\nPrivate Declare Function GetWindowThreadProcessId Lib &quot;user32&quot; (ByVal hWnd As Long, lpdwProcessId As Long) As Long\r\nPrivate Declare Function IIDFromString Lib &quot;ole32&quot; (lpsz As Any, lpiid As Any) As Long\r\nPrivate Declare Function ObjectFromLresult Lib &quot;oleacc&quot; (ByVal lResult As Long, riid As Any, ByVal wParam As Long, ppvObject As Object) As Long\r\nPrivate Declare Function RegisterWindowMessage Lib &quot;user32&quot; Alias &quot;RegisterWindowMessageA&quot; (ByVal lpString As String) As Long\r\nPrivate Declare Function SendMessageTimeout Lib &quot;user32&quot; Alias &quot;SendMessageTimeoutA&quot; (ByVal hWnd As Long, ByVal msg As Long, ByVal wParam As Long, ByVal lParam As Long, ByVal fuFlags As Long, ByVal uTimeout As Long, lpdwResult As Long) As Long\r\nPrivate Declare Sub Sleep Lib &quot;kernel32&quot; (ByVal dwMilliseconds As Long)\r\nPrivate Const GW_HWNDNEXT = &amp;H2\r\nPrivate hIES As Long\r\n\r\nPublic Sub Sample_EdgeDOM2()\r\n'Microsoft Edge\u3092DOM\u64cd\u4f5c(64\u30d3\u30c3\u30c8\u7248Excel\u3067\u306f\u30b3\u30fc\u30c9\u8981\u5909\u66f4)\r\n'\u203b\u4e0b\u8a18\u30da\u30fc\u30b8\u53c2\u7167\r\n'http:\/\/www.mvps.org\/emorcillo\/en\/code\/vb6\/iedom.shtml\r\n'http:\/\/kchon.blog111.fc2.com\/blog-entry-128.html\r\n'http:\/\/d.hatena.ne.jp\/yu-hr\/20100323\/1269355469\r\n'https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/20151015-00\/?p=91351\r\n'\r\n'\u203b\u4e0b\u8a18\u74b0\u5883\u3067\u52d5\u4f5c\u78ba\u8a8d\r\n'Microsoft Windows 10 Pro Insider Preview \u30d0\u30fc\u30b8\u30e7\u30f3:10.0.15019 \u30d3\u30eb\u30c9 15019\r\n'Microsoft Edge 40.15019.1000.0\r\n'Microsoft Excel 2016 MSO (16.0.7668.7078) 32 \u30d3\u30c3\u30c8\r\n  \r\n  Dim con As Object, items As Object, d As Object\r\n  Dim hWnd As Long, pid As Long\r\n  Const ProcessName = &quot;MicrosoftEdgeCP.exe&quot;\r\n  \r\n  '\u521d\u671f\u5316\r\n  hIES = 0\r\n  \r\n  'Edge\u8d77\u52d5\r\n  CreateObject(&quot;Shell.Application&quot;).ShellExecute &quot;microsoft-edge:http:\/\/www.yahoo.co.jp\/&quot;\r\n  Sleep 3000\r\n  \r\n  Set con = CreateObject(&quot;WbemScripting.SWbemLocator&quot;).ConnectServer\r\n  hWnd = GetTopWindow(0)\r\n  Do\r\n    If GetParent(hWnd) = 0 Then\r\n      '\u30a6\u30a3\u30f3\u30c9\u30a6\u30cf\u30f3\u30c9\u30eb\u304b\u3089\u30d7\u30ed\u30bb\u30b9ID\u3092\u53d6\u5f97\u3057\u3001Edge\u306e\u30a6\u30a3\u30f3\u30c9\u30a6\u304b\u3069\u3046\u304b\u3092\u5224\u5225\u3059\u308b\r\n      GetWindowThreadProcessId hWnd, pid\r\n      Set items = con.ExecQuery(&quot;Select * From Win32_Process Where (ProcessId = '&quot; &amp; pid &amp; &quot;') And (Name = '&quot; &amp; ProcessName &amp; &quot;')&quot;)\r\n      If items.Count &gt; 0 Then\r\n        'Edge\u306e\u5b50\u30a6\u30a3\u30f3\u30c9\u30a6\u5217\u6319\r\n        EnumChildWindows hWnd, AddressOf EnumChildProcIES, 0\r\n        If hIES &lt;&gt; 0 Then Exit Do\r\n      End If\r\n    End If\r\n    hWnd = GetNextWindow(hWnd, GW_HWNDNEXT)\r\n  Loop While hWnd &lt;&gt; 0\r\n  If hIES = 0 Then Exit Sub\r\n  \r\n  Set d = GetHTMLDocumentFromIES(hIES)\r\n  If Not d Is Nothing Then\r\n    'DOM\u64cd\u4f5c\r\n    d.getElementById(&quot;srchtxt&quot;).Value = &quot;\u521d\u5fc3\u8005\u5099\u5fd8\u9332\u30d6\u30ed\u30b0&quot;\r\n    d.getElementById(&quot;srchbtn&quot;).Click\r\n    While LCase(d.ReadyState) &lt;&gt; &quot;complete&quot;\r\n      Sleep 100\r\n    Wend\r\n    MsgBox d.Title, vbInformation + vbSystemModal\r\n  End If\r\nEnd Sub\r\n\r\nPrivate Function EnumChildProcIES(ByVal hWnd As Long, ByVal lParam As Long) As Long\r\n  Dim buf As String * 255\r\n  Dim ClassName As String\r\n   \r\n  GetClassName hWnd, buf, Len(buf)\r\n  ClassName = Left(buf, InStr(buf, vbNullChar) - 1)\r\n  If ClassName = &quot;Internet Explorer_Server&quot; Then\r\n    hIES = hWnd\r\n    EnumChildProcIES = False\r\n    Exit Function\r\n  End If\r\n  EnumChildProcIES = True\r\nEnd Function\r\n\r\nPrivate Function GetHTMLDocumentFromIES(ByVal hWnd As Long) As Object\r\n  Dim msg As Long, res As Long\r\n  Dim iid(0 To 3) As Long\r\n  Dim ret As Object, obj As Object\r\n  Const SMTO_ABORTIFHUNG = &amp;H2\r\n  Const IID_IHTMLDocument2 = &quot;{332C4425-26CB-11D0-B483-00C04FD90119}&quot;\r\n  \r\n  Set ret = Nothing '\u521d\u671f\u5316\r\n  msg = RegisterWindowMessage(&quot;WM_HTML_GETOBJECT&quot;)\r\n  SendMessageTimeout hWnd, msg, 0, 0, SMTO_ABORTIFHUNG, 1000, res\r\n  If res Then\r\n    IIDFromString StrPtr(IID_IHTMLDocument2), iid(0)\r\n    If ObjectFromLresult(res, iid(0), 0, obj) = 0 Then Set ret = obj\r\n  End If\r\n  Set GetHTMLDocumentFromIES = ret\r\nEnd Function<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/AutomateMicrosoftEdge_DOM_03_01.gif\" alt=\"\" width=\"616\" height=\"515\" class=\"alignnone size-full wp-image-7929\" \/><\/p>\n<p>\u30d7\u30ed\u30bb\u30b9\u306e\u7279\u5b9a\u51e6\u7406\u90e8\u5206\u304c\u91cd\u3044\u306e\u304c\u96e3\u70b9\u3067\u3059\u304c\u3001\u3053\u306e\u65b9\u6cd5\u3067\u3042\u308c\u3070\u591a\u5c11Edge\u306e\u69cb\u9020\u304c\u5909\u308f\u3063\u305f\u3068\u3057\u3066\u3082\u3001Internet Explorer_Server\u30af\u30e9\u30b9\u306e\u30a6\u30a3\u30f3\u30c9\u30a6\u3092\u6301\u3063\u3066\u3044\u308b\u9650\u308a\u3001DOM\u64cd\u4f5c\u3067\u304d\u308b\u306f\u305a\u3067\u3059\u3002<\/p>\n<p>\u3068\u306f\u3044\u3063\u3066\u3082\u3001\u4f55\u5ea6\u3082\u8a00\u3063\u3066\u3044\u308b\u901a\u308a\u4e0a\u8a18\u306e\u3088\u3046\u306a\u65b9\u6cd5\u306fMicrosoft\u304c\u63a8\u5968\u3057\u3066\u3044\u308b\u65b9\u6cd5\u3067\u306f\u7121\u3044\u305f\u3081\u3001\u4f55\u306e\u4fdd\u8a3c\u3082\u3042\u308a\u307e\u305b\u3093\u3002<br \/>\n\u8a00\u8a9e\u554f\u308f\u305a\u3001Microsoft Edge\u306e\u64cd\u4f5c\u3092\u81ea\u52d5\u5316\u3057\u305f\u3044\u5834\u5408\u306f\u3001\u7d20\u76f4\u306b\u300c<a href=\"https:\/\/developer.microsoft.com\/en-us\/microsoft-edge\/tools\/webdriver\/\" title=\"WebDriver - Microsoft Edge Development\" target=\"_blank\">WebDriver<\/a>\u300d\u3092\u4f7f\u3046\u306e\u304c\u826f\u3044\u3067\u3057\u3087\u3046\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","protected":false},"excerpt":{"rendered":"\u6628\u65e5\u306e\u8a18\u4e8b\u3067\u3001Microsoft Edge\u3092\u64cd\u4f5c\u3059\u308bVBA\u30b3\u30fc\u30c9\u3092\u6539\u3081\u3066\u66f8\u304d\u307e\u3057\u305f\u304c\u3001\u6628\u65e5\u306e\u30b3\u30fc\u30c9\u306f\u300cTabWindowClass\u300d\u30af\u30e9\u30b9\u306e\u30a6\u30a3\u30f3\u30c9\u30a6\u3092\u6c7a\u3081\u6253\u3061\u3057\u3066\u3044\u308b\u306e\u3067\u3001Edge\u306e\u4ed5\u69d8\u5909\u66f4\u306b\u3088\u308a\u52d5\u4f5c\u3057\u306a\u304f\u306a\u308b\u53ef\u80fd\u6027\u304c [&hellip;]","protected":false},"author":1,"featured_media":7115,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"[\u30102017\u5e741\u6708\u7248\u3011Microsoft Edge\u3092\u64cd\u4f5c\u3059\u308bVBA\u30de\u30af\u30ed(DOM\u7de8)(2)]","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,132,25,133],"tags":[],"class_list":["post-7928","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-office","category-excel-office","category-windows10","category-windows","category-microsoft-edge"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/eyecatch-MicrosoftEdge.png","jetpack_shortlink":"https:\/\/wp.me\/p4UZZr-23S","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/7928","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=7928"}],"version-history":[{"count":2,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/7928\/revisions"}],"predecessor-version":[{"id":7931,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/7928\/revisions\/7931"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/media\/7115"}],"wp:attachment":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7928"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7928"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7928"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}