{"id":851,"date":"2020-12-19T11:05:17","date_gmt":"2020-12-19T02:05:17","guid":{"rendered":"https:\/\/beiyan-tool.info\/?p=851"},"modified":"2020-12-19T11:05:17","modified_gmt":"2020-12-19T02:05:17","slug":"vba%e3%81%a7%e3%83%95%e3%82%a9%e3%83%ab%e3%83%80%e3%81%ae%e3%83%97%e3%83%ad%e3%83%91%e3%83%86%e3%82%a3%e3%81%ae%e3%82%b5%e3%82%a4%e3%82%ba%e3%80%81%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e6%95%b0","status":"publish","type":"post","link":"https:\/\/beiyan-tool.info\/?p=851","title":{"rendered":"VBA\u3067\u30d5\u30a9\u30eb\u30c0\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u306e\u30b5\u30a4\u30ba\u3001\u30d5\u30a1\u30a4\u30eb\u6570\u3001\u30d5\u30a9\u30eb\u30c0\u6570\u3092\u53d6\u5f97\u3059\u308b\u30b3\u30fc\u30c9"},"content":{"rendered":"<p>VBA\u3067\u30d5\u30a9\u30eb\u30c0\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u306e\u30b5\u30a4\u30ba\u3001\u30d5\u30a1\u30a4\u30eb\u6570\u3001\u30d5\u30a9\u30eb\u30c0\u6570\u3092\u53d6\u5f97\u3059\u308b\u30b3\u30fc\u30c9\u3092\u66f8\u304d\u307e\u3057\u305f\u3002<br \/>\n\u30d5\u30a9\u30eb\u30c0\u3092\u53f3\u30af\u30ea\u30c3\u30af\u3057\u3066\u3001\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u8868\u793a\u3059\u308b\u3068\u304d\u3068\u4f3c\u305f\u3088\u3046\u306a\u5185\u5bb9\u3092\u53d6\u5f97\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u30d5\u30a9\u30eb\u30c0\u30b5\u30a4\u30ba\u306f\u3001FileSystemObject\u3067\u53d6\u5f97\u3067\u304d\u307e\u3059\u304c\u3001\u30b5\u30d6\u30d5\u30a9\u30eb\u30c0\u3092\u542b\u3081\u305f\u30d5\u30a9\u30eb\u30c0\u6570\u3001\u30d5\u30a1\u30a4\u30eb\u6570\u306f\u518d\u5e30\u7684\u306b\u53d6\u5f97\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\t<p style=\"color:#666;margin-bottom:5px;\">\u30b9\u30dd\u30f3\u30b5\u30fc\u30ea\u30f3\u30af<\/p>\n\t<div class=\"middle-ad\">\n\t\t\t\t\t\t\t<div class=\"textwidget\"><p><script async src=\"https:\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script><br \/>\n<!-- \u6b66\u8853\u304c\u597d\u304d --><br \/>\n<ins class=\"adsbygoogle\"\n     style=\"display:block\"\n     data-ad-client=\"ca-pub-8986630938426235\"\n     data-ad-slot=\"2584434263\"\n     data-ad-format=\"auto\"\n     data-full-width-responsive=\"true\"><\/ins><br \/>\n<script>\n(adsbygoogle = window.adsbygoogle || []).push({});\n<\/script><\/p>\n<\/div>\n\t\t\t\t\t\t<\/div>\n\n\n<p>\u4ee5\u4e0b\u3001VBA\u3067\u30d5\u30a9\u30eb\u30c0\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u306e\u30b5\u30a4\u30ba\u3001\u30d5\u30a1\u30a4\u30eb\u6570\u3001\u30d5\u30a9\u30eb\u30c0\u6570\u3092\u53d6\u5f97\u3059\u308b\u30b3\u30fc\u30c9\u3067\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true \" title=\"VBA\u3067\u30d5\u30a9\u30eb\u30c0\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u306e\u30b5\u30a4\u30ba\u3001\u30d5\u30a1\u30a4\u30eb\u6570\u3001\u30d5\u30a9\u30eb\u30c0\u6570\u3092\u53d6\u5f97\u3059\u308b\u30b3\u30fc\u30c9\">Sub \u30d5\u30a9\u30eb\u30c0\u60c5\u5831\u53d6\u5f97()\r\n\r\n    Dim dblSize As Double\r\n    Dim sDir As String\r\n    sDir = \"C:\\Temp\"\r\n    \r\n    dblSize = \u30d5\u30a9\u30eb\u30c0\u30b5\u30a4\u30ba\u53d6\u5f97(sDir)\r\n    \r\n    Range(\"A1\").Value = dblSize\r\n    Range(\"B1\").Value = \"\u30d0\u30a4\u30c8\"\r\n    Range(\"A2\").Value = Int(dblSize \/ 1024)\r\n    Range(\"B2\").Value = \"KB\"\r\n    Range(\"A3\").NumberFormatLocal = \"0.00\"\r\n    Range(\"A3\").Value = dblSize \/ 1024 \/ 1024\r\n    Range(\"B3\").Value = \"MB\"\r\n    Range(\"A4\").NumberFormatLocal = \"0.00000\"\r\n    Range(\"A4\").Value = dblSize \/ 1024 \/ 1024 \/ 1024\r\n    Range(\"B4\").Value = \"GB\"\r\n\r\n\r\n    Dim lFolderCount As Long\r\n    Dim lFileCount As Long\r\n    \r\n    \u30d5\u30a9\u30eb\u30c0\u6570\u30d5\u30a1\u30a4\u30eb\u6570\u53d6\u5f97 sDir, lFolderCount, lFileCount\r\n    \r\n    \r\n    Range(\"A5\").Value = lFolderCount\r\n    Range(\"B5\").Value = \"\u30d5\u30a9\u30eb\u30c0\u6570\"\r\n    Range(\"A6\").Value = lFileCount\r\n    Range(\"B6\").Value = \"\u30d5\u30a1\u30a4\u30eb\u6570\"\r\n\r\n\r\nEnd Sub\r\n\r\nPrivate Function \u30d5\u30a9\u30eb\u30c0\u30b5\u30a4\u30ba\u53d6\u5f97(sDir As String) As Double\r\n\r\n    Dim fso As Object\r\n    Set fso = CreateObject(\"Scripting.FileSystemObject\")\r\n\r\n    \u30d5\u30a9\u30eb\u30c0\u30b5\u30a4\u30ba\u53d6\u5f97 = fso.GetFolder(sDir).Size\r\n\r\nEnd Function\r\n\r\n\r\nPrivate Sub \u30d5\u30a9\u30eb\u30c0\u6570\u30d5\u30a1\u30a4\u30eb\u6570\u53d6\u5f97(strTargetDir As String, ByRef lFolderCount As Long, ByRef lFileCount As Long)\r\n\r\n    Dim fso As Object\r\n    Dim folder As Object\r\n    Dim subfolder As Object\r\n    Dim file As Object\r\n  \r\n    Set fso = CreateObject(\"Scripting.FileSystemObject\")\r\n    Set folder = fso.GetFolder(strTargetDir)\r\n    \r\n    lFolderCount = lFolderCount + folder.subFolders.Count\r\n    lFileCount = lFileCount + folder.Files.Count\r\n\r\n    For Each subfolder In folder.subFolders\r\n        '\u518d\u5e30\u7684\u306b\u30c1\u30a7\u30c3\u30af\r\n        \u30d5\u30a9\u30eb\u30c0\u6570\u30d5\u30a1\u30a4\u30eb\u6570\u53d6\u5f97 subfolder.Path, lFolderCount, lFileCount\r\n    Next subfolder\r\n\r\nEnd Sub\r\n\r\n\r\n\r\n\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>VBA\u3067\u30d5\u30a9\u30eb\u30c0\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u306e\u30b5\u30a4\u30ba\u3001\u30d5\u30a1\u30a4\u30eb\u6570\u3001\u30d5\u30a9\u30eb\u30c0\u6570\u3092\u53d6\u5f97\u3059\u308b\u30b3\u30fc\u30c9\u3092\u66f8\u304d\u307e\u3057\u305f\u3002 \u30d5\u30a9\u30eb\u30c0\u3092\u53f3\u30af\u30ea\u30c3\u30af\u3057\u3066\u3001\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u8868\u793a\u3059\u308b\u3068\u304d\u3068\u4f3c\u305f\u3088\u3046\u306a\u5185\u5bb9\u3092\u53d6\u5f97\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002 \u30d5\u30a9\u30eb\u30c0\u30b5\u30a4\u30ba &#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[],"class_list":["post-851","post","type-post","status-publish","format-standard","hentry","category-programming"],"_links":{"self":[{"href":"https:\/\/beiyan-tool.info\/index.php?rest_route=\/wp\/v2\/posts\/851","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/beiyan-tool.info\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/beiyan-tool.info\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/beiyan-tool.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/beiyan-tool.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=851"}],"version-history":[{"count":1,"href":"https:\/\/beiyan-tool.info\/index.php?rest_route=\/wp\/v2\/posts\/851\/revisions"}],"predecessor-version":[{"id":852,"href":"https:\/\/beiyan-tool.info\/index.php?rest_route=\/wp\/v2\/posts\/851\/revisions\/852"}],"wp:attachment":[{"href":"https:\/\/beiyan-tool.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=851"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/beiyan-tool.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=851"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/beiyan-tool.info\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=851"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}