{"id":7356,"date":"2016-09-28T11:39:19","date_gmt":"2016-09-28T02:39:19","guid":{"rendered":"https:\/\/www.ka-net.org\/blog\/?p=7356"},"modified":"2016-09-28T11:39:19","modified_gmt":"2016-09-28T02:39:19","slug":"%e3%83%87%e3%82%a3%e3%82%b9%e3%83%97%e3%83%ac%e3%82%a4%e3%81%ae%e3%82%b5%e3%82%a4%e3%82%ba%e3%82%92%e5%8f%96%e5%be%97%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=7356","title":{"rendered":"\u30c7\u30a3\u30b9\u30d7\u30ec\u30a4\u306e\u30b5\u30a4\u30ba\u3092\u53d6\u5f97\u3059\u308bVBA\u30de\u30af\u30ed"},"content":{"rendered":"<p>\u300c<span style=\"color: #ff0000; font-weight: bold;\">VBA \u30c7\u30a3\u30b9\u30d7\u30ec\u30a4 \u5e45 \u9ad8\u3055<\/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\u30de\u30af\u30ed\u3067\u30c7\u30a3\u30b9\u30d7\u30ec\u30a4\u306e\u89e3\u50cf\u5ea6\u3092\u53d6\u5f97\u3059\u308b\u65b9\u6cd5\u3092\u63a2\u3057\u3066\u3044\u308b\u65b9\u3060\u308d\u3046\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u30de\u30af\u30ed\u3067\u30c7\u30a3\u30b9\u30d7\u30ec\u30a4\u306e\u9ad8\u3055\u3084\u5e45\u3092\u53d6\u5f97\u3059\u308b\u5834\u5408\u3001\u624b\u8efd\u306a\u306e\u306fWMI\u306e\u300c<a href=\"https:\/\/msdn.microsoft.com\/ja-jp\/library\/aa394122.aspx\" title=\"Win32_DesktopMonitor class (Windows)\" target=\"_blank\">Win32_DesktopMonitor<\/a>\u300d\u30af\u30e9\u30b9\u3084\u300c<a href=\"https:\/\/msdn.microsoft.com\/ja-jp\/library\/aa394512.aspx\" title=\"Win32_VideoController class (Windows)\" target=\"_blank\">Win32_VideoController<\/a>\u300d\u30af\u30e9\u30b9\u3092\u5229\u7528\u3059\u308b\u65b9\u6cd5\u3067\u3059\u3002<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">Public Sub Sample1()\r\n'Win32_DesktopMonitor\u30af\u30e9\u30b9\u5229\u7528\r\n  Dim items As Object\r\n  Dim item As Object\r\n\r\n  Set items = CreateObject(&quot;WbemScripting.SWbemLocator&quot;) _\r\n              .ConnectServer.ExecQuery(&quot;Select * From Win32_DesktopMonitor&quot;)\r\n  For Each item In items\r\n    Debug.Print &quot;Name:&quot; &amp; item.Name, _\r\n                &quot;DeviceID:&quot; &amp; item.DeviceID, _\r\n                &quot;ScreenWidth:&quot; &amp; item.ScreenWidth, _\r\n                &quot;ScreenHeight:&quot; &amp; item.ScreenHeight\r\n  Next\r\nEnd Sub\r\n\r\nPublic Sub Sample2()\r\n'Win32_VideoController\u30af\u30e9\u30b9\u5229\u7528\r\n  Dim items As Object\r\n  Dim item As Object\r\n  \r\n  Set items = CreateObject(&quot;WbemScripting.SWbemLocator&quot;) _\r\n              .ConnectServer.ExecQuery(&quot;Select * From Win32_VideoController&quot;)\r\n  For Each item In items\r\n    Debug.Print &quot;Caption:&quot; &amp; item.Caption, _\r\n                &quot;DeviceID:&quot; &amp; item.DeviceID, _\r\n                &quot;CurrentHorizontalResolution:&quot; &amp; item.CurrentHorizontalResolution, _\r\n                &quot;CurrentVerticalResolution:&quot; &amp; item.CurrentVerticalResolution\r\n  Next\r\nEnd Sub<\/pre>\n<p>\u305f\u3060\u3001<a href=\"http:\/\/p774.blog.fc2.com\/blog-entry-27.html\" title=\"[WSH Panel Mod] foobar2000\u304b\u3089\u8907\u6570\u306e\u30e2\u30cb\u30bf\u306e\u89e3\u50cf\u5ea6\u3068\u304b\u30d7\u30e9\u30a4\u30de\u30ea\u304b\u3069\u3046\u304b\u3092\u53d6\u5f97\u3059\u308b\" target=\"_blank\">\u3053\u3061\u3089\u306e\u8a18\u4e8b<\/a>\u306b\u3088\u308b\u3068\u3001\u6b63\u3057\u304f\u30b5\u30a4\u30ba\u3092\u53d6\u5f97\u3067\u304d\u306a\u3044\u5834\u5408\u3082\u3042\u308b\u3088\u3046\u306a\u306e\u3067\u3001PowerShell\u7d4c\u7531\u3067.NET\u306e\u300c<a href=\"https:\/\/msdn.microsoft.com\/ja-jp\/library\/system.windows.forms.screen.allscreens.aspx\" title=\"Screen.AllScreens \u30d7\u30ed\u30d1\u30c6\u30a3 (System.Windows.Forms)\" target=\"_blank\">Screen.AllScreens<\/a>\u300d\u30d7\u30ed\u30d1\u30c6\u30a3\u304b\u3089\u5024\u3092\u53d6\u5f97\u3059\u308b\u30b3\u30fc\u30c9\u3082\u8003\u3048\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">Public Sub Sample3()\r\n'System.Windows.Forms.Screen.AllScreens\u30d7\u30ed\u30d1\u30c6\u30a3\u5229\u7528\r\n  Dim cmd As String\r\n  Dim ret As String\r\n  Dim v As Variant, vv As Variant\r\n  Dim i As Long\r\n   \r\n  'PowerShell\u306e\u5b9f\u884c\u78ba\u8a8d\r\n  On Error Resume Next\r\n  Shell &quot;PowerShell -Version&quot;, vbHide\r\n  If Err.Number &lt;&gt; 0 Then Exit Sub\r\n  On Error GoTo 0\r\n  \r\n  cmd = &quot;PowerShell -Command Add-Type -AssemblyName System.Windows.Forms;$str='';foreach($item in &#x5B;Windows.Forms.Screen]::AllScreens){$str+=$item.DeviceName+','+$item.BitsPerPixel+','+$item.Primary+','+$item.Bounds.Width+','+$item.Bounds.Height+':'};$str=$str.Remove($str.Length-1,1);Write-Host $str;&quot;\r\n  ret = CreateObject(&quot;WScript.Shell&quot;).Exec(cmd).StdOut.ReadLine\r\n  v = Split(ret, &quot;:&quot;) 'PowerShell\u306e\u5b9f\u884c\u7d50\u679c\u3092\u6307\u5b9a\u3057\u305f\u533a\u5207\u308a\u6587\u5b57\u3067\u5206\u5272\r\n  For i = LBound(v) To UBound(v)\r\n    vv = Split(v(i), &quot;,&quot;)\r\n    Debug.Print &quot;DeviceName:&quot; &amp; vv(0), _\r\n                &quot;BitsPerPixel:&quot; &amp; vv(1), _\r\n                &quot;Primary:&quot; &amp; vv(2), _\r\n                &quot;Width:&quot; &amp; vv(3), _\r\n                &quot;Height:&quot; &amp; vv(4)\r\n  Next\r\nEnd Sub<\/pre>\n<p>PowerShell\u304c\u5b9f\u884c\u3067\u304d\u308b\u74b0\u5883\u304c\u524d\u63d0\u3068\u306a\u308a\u307e\u3059\u304c\u3001WMI\u3067\u4e0a\u624b\u304f\u3044\u304b\u306a\u3044\u5834\u5408\u306f\u3001\u3053\u3061\u3089\u306e\u30b3\u30fc\u30c9\u3082\u304a\u8a66\u3057\u304f\u3060\u3055\u3044\u3002<\/p>\n<h4 class=\"style4a\">\u53c2\u8003Web\u30da\u30fc\u30b8<\/h4>\n<ul>\n<li>[WSH Panel Mod] foobar2000\u304b\u3089\u8907\u6570\u306e\u30e2\u30cb\u30bf\u306e\u89e3\u50cf\u5ea6\u3068\u304b\u30d7\u30e9\u30a4\u30de\u30ea\u304b\u3069\u3046\u304b\u3092\u53d6\u5f97\u3059\u308b<\/li>\n<li style=\"list-style-type:none;\"><a href=\"http:\/\/p774.blog.fc2.com\/blog-entry-27.html\" target=\"_blank\" title=\"[WSH Panel Mod] foobar2000\u304b\u3089\u8907\u6570\u306e\u30e2\u30cb\u30bf\u306e\u89e3\u50cf\u5ea6\u3068\u304b\u30d7\u30e9\u30a4\u30de\u30ea\u304b\u3069\u3046\u304b\u3092\u53d6\u5f97\u3059\u308b\">http:\/\/p774.blog.fc2.com\/blog-entry-27.html<\/a><\/li>\n<li>Get Screen resolution using WMI\/powershell in Windows 7<\/li>\n<li style=\"list-style-type:none;\"><a href=\"http:\/\/stackoverflow.com\/questions\/7967699\/get-screen-resolution-using-wmi-powershell-in-windows-7\" target=\"_blank\" title=\"Get Screen resolution using WMI\/powershell in Windows 7\">http:\/\/stackoverflow.com\/questions\/7967699\/get-screen-resolution-using-wmi-powershell-in-windows-7<\/a><\/li>\n<li>VBScript to read resolution of primary monitor not always working<\/li>\n<li style=\"list-style-type:none;\"><a href=\"https:\/\/social.technet.microsoft.com\/Forums\/en-US\/ITCG\/thread\/235c064b-10a6-4d2d-b24b-68ae60c1a506\" target=\"_blank\" title=\"VBScript to read resolution of primary monitor not always working\">https:\/\/social.technet.microsoft.com\/Forums\/en-US\/ITCG\/thread\/235c064b-10a6-4d2d-b24b-68ae60c1a506<\/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":"\u300cVBA \u30c7\u30a3\u30b9\u30d7\u30ec\u30a4 \u5e45 \u9ad8\u3055\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 \u30de\u30af\u30ed\u3067\u30c7\u30a3\u30b9\u30d7\u30ec\u30a4\u306e\u89e3\u50cf\u5ea6\u3092\u53d6\u5f97\u3059\u308b\u65b9\u6cd5\u3092\u63a2\u3057\u3066\u3044\u308b\u65b9\u3060\u308d\u3046\u3068\u601d\u3044\u307e\u3059\u3002 \u30de\u30af\u30ed\u3067\u30c7\u30a3\u30b9\u30d7\u30ec\u30a4\u306e\u9ad8\u3055\u3084\u5e45\u3092\u53d6\u5f97\u3059\u308b\u5834\u5408\u3001\u624b\u8efd\u306a\u306e\u306fWM [&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":"PowerShell\u7d4c\u7531\u3067.NET\u306eScreen.AllScreens\u30d7\u30ed\u30d1\u30c6\u30a3\u304b\u3089\u5024\u3092\u53d6\u5f97\u3059\u308b\u30b3\u30fc\u30c9\u3082\u8f09\u305b\u3066\u307f\u307e\u3057\u305f\u3002  [\u30c7\u30a3\u30b9\u30d7\u30ec\u30a4\u306e\u30b5\u30a4\u30ba\u3092\u53d6\u5f97\u3059\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-7356","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-1UE","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/7356","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=7356"}],"version-history":[{"count":1,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/7356\/revisions"}],"predecessor-version":[{"id":7357,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/7356\/revisions\/7357"}],"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=7356"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7356"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7356"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}