{"id":2300,"date":"2016-10-23T15:52:09","date_gmt":"2016-10-23T06:52:09","guid":{"rendered":"http:\/\/1bed.allright.life\/?p=2300"},"modified":"2020-04-18T21:07:41","modified_gmt":"2020-04-18T12:07:41","slug":"post-2300","status":"publish","type":"post","link":"https:\/\/1bed.allright.life\/?p=2300","title":{"rendered":"Excel \u30de\u30af\u30ed\u306f\u30bf\u30b9\u30af\u30b9\u30b1\u30b8\u30e5\u30fc\u30e9\u3067\u5b9f\u884c\u3067\u304d\u308b\u306e\u304b \uff5eExcel \u3060\u3051\u3067\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u30ed\u30b0\u3092\u53ce\u96c6\u3059\u308b\uff5e"},"content":{"rendered":"<h1>Excel \u30de\u30af\u30ed\u306f\u30bf\u30b9\u30af\u30b9\u30b1\u30b8\u30e5\u30fc\u30e9\u3067\u5b9f\u884c\u3067\u304d\u308b\u306e\u304b<\/h1>\n<p>PowerShell \u3067\u30ed\u30b0\u53ce\u96c6\u30fb\u7cbe\u67fb\u3092\u3057\u3066\u3001\u78ba\u8a8d\u7528\u306e Excel \u306b\u4fdd\u5b58\u3059\u308b\u3002<br \/>\n\u300cExcel \u304c\u81ea\u5206\u81ea\u8eab\u3067\u3084\u308c\u3088\u300d\u3068\u8003\u3048\u3066\u3057\u307e\u3044\u3001\u300c\u305d\u3082\u305d\u3082 Excel \u306e\u30de\u30af\u30ed\u3092\u30bf\u30b9\u30af\u30b9\u30b1\u30b8\u30e5\u30fc\u30e9\u30fc\u304b\u3089\u5b9f\u884c\u3067\u304d\u308b\u306e\u304b\u306a\uff1f\u300d\u3068\u3044\u3046\u3068\u3053\u308d\u304b\u3089\u78ba\u8a8d\u3057\u3066\u307f\u3088\u3046\u3068\u601d\u3044\u8a66\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>\u4f53\u8abf\u5d29\u3057\u3066\u3044\u3066\u6687\u3067\u3059\u3057\u3001\u305f\u3060\u8a66\u3059\u3060\u3051\u3067\u306f\u9762\u767d\u5473\u306b\u304b\u3051\u305f\u306e\u3067\u3001\u3064\u3044\u3067\u306b\u7c21\u6613\u7684\u306a\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u30ed\u30b0\u53d6\u5f97\u3092\u884c\u306a\u3063\u3066\u307f\u307e\u3059\u3002\u300c\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u30e2\u30cb\u30bf\u30fc\u4f7f\u3048\u3070\uff1f\u300d\u3068\u601d\u308f\u308c\u308b\u65b9\u3082\u3044\u308b\u3067\u3057\u3087\u3046\u304c\u3001\u697d\u3057\u304f\u3084\u3063\u3066\u3044\u308b\u306e\u3067\u305d\u3063\u3068\u3057\u3066\u304a\u3044\u3066\u4e0b\u3055\u3044\uff3e\uff3e\uff1b<\/p>\n<p>\u6570\u30ab\u6708\u3076\u308a\u306b\u30de\u30af\u30ed\u3092\u89e6\u308b\u3068\u4f5c\u308a\u65b9\u7b49\u3092\u3059\u3063\u304b\u308a\u5fd8\u308c\u3066\u3044\u305f\u306e\u3067\u3001\u500b\u4eba\u7684\u306a\u5099\u5fd8\u9332\u3068\u3057\u3066\u3082\u3001\u79c1\u304c\u5206\u304b\u308b\u7bc4\u56f2\u3067\u5c11\u3057\u8a73\u3057\u3081\u306b\u66f8\u3044\u3066\u307f\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002\u3054\u6307\u6458\u304c\u3042\u308c\u3070\u512a\u3057\u304f\u304a\u9858\u3044\u81f4\u3057\u307e\u3059\u3002<\/p>\n<h1>\u3084\u308b\u3053\u3068<\/h1>\n<ul>\n<li>Excel \u30de\u30af\u30ed\u3067\u3001CPU\u3001Memory\u3001Disk \u306e\u72b6\u614b\u3092\u53d6\u5f97\u3059\u308b<\/li>\n<li>Excel \u30de\u30af\u30ed\u3092\u30bf\u30b9\u30af\u30b9\u30b1\u30b8\u30e5\u30fc\u30e9\u30fc\u3067\u5b9f\u884c\u3059\u308b<\/li>\n<\/ul>\n<h1>\u691c\u8a3c\u74b0\u5883<\/h1>\n<ul>\n<li>Windows10 Pro<\/li>\n<li>Excel 2016<\/li>\n<\/ul>\n<h1>1. \u30de\u30af\u30ed\u6709\u52b9\u30d6\u30c3\u30af\u306e\u4f5c\u6210<\/h1>\n<p><a href=\"https:\/\/github.com\/miyamiya\/Learnning_ExcelMacro\/blob\/master\/MachinePerformance\/performance.xlsm\">\u3061\u306a\u307f\u306b\u4f5c\u6210\u5f8c\u306e\u30d5\u30a1\u30a4\u30eb\u306f\u3053\u3061\u3089\u306b\u306a\u308a\u307e\u3059<\/a><br \/>\n\u624b\u3063\u53d6\u308a\u65e9\u304f\u8a66\u3057\u3066\u307f\u305f\u3044\u65b9\u306f\u3001\u4e0a\u8a18\u30d5\u30a1\u30a4\u30eb\u3092\u4f7f\u3044\u3001 <a href=\"http:\/\/1bed.allright.life\/?p=2300&amp;preview=true#2\">2. \u30bf\u30b9\u30af\u30b9\u30b1\u30b8\u30e5\u30fc\u30e9\u30fc\u3078\u306e\u8a2d\u5b9a<\/a> \u304b\u3089\u8aad\u3080\u3053\u3068\u3092\u304a\u3059\u3059\u3081\u3057\u307e\u3059\u3002<\/p>\n<h2>1-1. \u4e0b\u6e96\u5099<\/h2>\n<h3>\u30de\u30af\u30ed\u3092\u4f5c\u308b\u524d\u306b<\/h3>\n<ol>\n<li>\u4e0a\u90e8\u30e1\u30cb\u30e5\u30fc\u306e <strong>\u30d5\u30a1\u30a4\u30eb<\/strong> \u3092\u30af\u30ea\u30c3\u30af<\/li>\n<li>\u5de6\u90e8\u30e1\u30cb\u30e5\u30fc\u306e <strong>\u30aa\u30d7\u30b7\u30e7\u30f3<\/strong> \u3092\u30af\u30ea\u30c3\u30af<\/li>\n<li>Excel \u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u30a6\u30a3\u30f3\u30c9\u30a6\u3001\u5de6\u90e8\u30e1\u30cb\u30e5\u30fc <strong>\u30ea\u30dc\u30f3\u306e\u30e6\u30fc\u30b6\u30fc\u8a2d\u5b9a<\/strong> \u3092\u30af\u30ea\u30c3\u30af<\/li>\n<li>\u4e2d\u592e\u90e8\u306e\u5de6\u30ea\u30b9\u30c8\u304b\u3089 <strong>\u958b\u767a<\/strong> \u3092\u9078\u629e\u3057\u3001 <strong>\u8ffd\u52a0 &gt;&gt;<\/strong> \u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3001\u305d\u306e\u5f8c <strong>OK<\/strong> \u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af<br \/>\n\u958b\u767a\u3092\u3059\u308b\u6642\u306b\u306f\u3001\u300c\u958b\u767a\u300d\u306e\u30ea\u30dc\u30f3\u3092\u8868\u793a\u3057\u305f\u65b9\u304c\u4fbf\u5229\u3067\u3059\u3002<br \/>\n<a href=\"http:\/\/1bed.allright.life\/wp-content\/uploads\/2016\/10\/1.png\" data-rel=\"lightbox-image-0\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" src=\"http:\/\/1bed.allright.life\/wp-content\/uploads\/2016\/10\/1-300x44.png\" alt=\"\" \/><\/a><\/li>\n<\/ol>\n<h3>\u30c7\u30fc\u30bf\u7528\u30b7\u30fc\u30c8\u306e\u4f5c\u6210<\/h3>\n<p>\u30de\u30af\u30ed\u304b\u3089\u884c\u3063\u3066\u3082\u826f\u3044\u306e\u3067\u3059\u304c\u30011 \u56de\u3057\u304b\u884c\u308f\u306a\u3044\u306e\u3067\u624b\u4f5c\u696d\u3067\u4f5c\u308a\u307e\u3057\u305f\u3002<\/p>\n<ul>\n<li>\n<p>cpu \u30b7\u30fc\u30c8<\/p>\n<table>\n<thead>\n<tr>\n<th>\u5217<\/th>\n<th>\u5024<\/th>\n<th>\u66f8\u5f0f\u8a2d\u5b9a<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>A<\/td>\n<td>\u540d\u524d<\/td>\n<td>\u6587\u5b57\u5217<\/td>\n<\/tr>\n<tr>\n<td>B<\/td>\n<td>\u4f7f\u7528\u7387<\/td>\n<td>\u6570\u5024<\/td>\n<\/tr>\n<tr>\n<td>C<\/td>\n<td>\u53d6\u5f97\u65e5\u6642<\/td>\n<td>\u30e6\u30fc\u30b6\u30fc\u5b9a\u7fa9\u3001 yyyy\/m\/d hh:mm:ss<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li>\n<p>memory \u30b7\u30fc\u30c8<\/p>\n<table>\n<thead>\n<tr>\n<th>\u5217<\/th>\n<th>\u5024<\/th>\n<th>\u66f8\u5f0f\u8a2d\u5b9a<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>A<\/td>\n<td>\u30bf\u30a4\u30d7<\/td>\n<td>\u6587\u5b57\u5217<\/td>\n<\/tr>\n<tr>\n<td>B<\/td>\n<td>\u7a7a\u304d\u5bb9\u91cf<\/td>\n<td>\u6570\u5024<\/td>\n<\/tr>\n<tr>\n<td>C<\/td>\n<td>\u5168\u4f53\u5bb9\u91cf<\/td>\n<td>\u6570\u5024<\/td>\n<\/tr>\n<tr>\n<td>D<\/td>\n<td>\u53d6\u5f97\u65e5\u6642<\/td>\n<td>\u30e6\u30fc\u30b6\u30fc\u5b9a\u7fa9\u3001 yyyy\/m\/d hh:mm:ss<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li>\n<p>\u30b7\u30fc\u30c8<\/p>\n<table>\n<thead>\n<tr>\n<th>\u5217<\/th>\n<th>\u5024<\/th>\n<th>\u66f8\u5f0f\u8a2d\u5b9a<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>A<\/td>\n<td>\u30bf\u30a4\u30d7<\/td>\n<td>\u6587\u5b57\u5217<\/td>\n<\/tr>\n<tr>\n<td>B<\/td>\n<td>\u7a7a\u304d\u5bb9\u91cf<\/td>\n<td>\u6570\u5024<\/td>\n<\/tr>\n<tr>\n<td>C<\/td>\n<td>\u5168\u4f53\u5bb9\u91cf<\/td>\n<td>\u6570\u5024<\/td>\n<\/tr>\n<tr>\n<td>D<\/td>\n<td>\u53d6\u5f97\u65e5\u6642<\/td>\n<td>\u30e6\u30fc\u30b6\u30fc\u5b9a\u7fa9\u3001 yyyy\/m\/d hh:mm:ss<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<\/ul>\n<p>\u307e\u305a\u306f\u30de\u30af\u30ed\u306a\u3057\u306e\u7d20\u306e Excel \u30d5\u30a1\u30a4\u30eb\u3068\u3057\u3066\u4fdd\u5b58\u3057\u307e\u3057\u305f\u3002<br \/>\n<a href=\"https:\/\/github.com\/miyamiya\/Learnning_ExcelMacro\/blob\/master\/MachinePerformance\/performance.xlsx\">\u3053\u3053\u3067\u4f5c\u6210\u3055\u308c\u305f Excel \u30d5\u30a1\u30a4\u30eb\u306f\u3053\u3061\u3089\u306b\u306a\u308a\u307e\u3059 &gt;&gt; performance.xlsx<\/a><\/p>\n<h2>1-2. \u30de\u30af\u30ed\u3092\u7d44\u3080<\/h2>\n<p>\u300c\u958b\u767a\u300d\u30ea\u30dc\u30f3\u304b\u3089\u3001<strong>Visual Basic<\/strong><br \/>\n\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u6b21\u306e\u3088\u3046\u306a\u30a6\u30a3\u30f3\u30c9\u30a6\u304c\u958b\u304d\u307e\u3059\u3002<\/p>\n<p><a href=\"http:\/\/1bed.allright.life\/wp-content\/uploads\/2016\/10\/2.png\" data-rel=\"lightbox-image-1\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" src=\"http:\/\/1bed.allright.life\/wp-content\/uploads\/2016\/10\/2-300x198.png\" alt=\"\" \/><\/a><\/p>\n<p>\u5de6\u306e\u30a6\u30a3\u30f3\u30c9\u30a6\u306b\u3042\u308b <strong>ThisWorkbook<\/strong> \u3092\u30c0\u30d6\u30eb\u30af\u30ea\u30c3\u30af\u3057\u3066\u3001\u305d\u306e\u4e2d\u306b\u30de\u30af\u30ed\u3092\u8a18\u8ff0\u3057\u3066\u3044\u304d\u307e\u3059\u3002<br \/>\n<a href=\"https:\/\/github.com\/miyamiya\/Learnning_ExcelMacro\/blob\/master\/MachinePerformance\/ThisWorkbook.vbs\">\u4eca\u56de\u79c1\u304c\u66f8\u3044\u305f\u30b3\u30fc\u30c9\u306f\u3053\u3061\u3089\u306b\u306a\u308a\u307e\u3059 &gt;&gt; ThisWorkbook.vbs<\/a><\/p>\n<p>\u9700\u8981\u304c\u3042\u308b\u304b\u5224\u308a\u307e\u305b\u3093\u304c\u5c11\u3057\u8aac\u660e\u3092\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<hr \/>\n<pre><code class=\"language-vbnet\">&#039; used disk-sheet\nConst DISK_NAME = 1\nConst DISK_FREE = 2\nConst DISK_TOTAL = 3\nConst DISK_CREATEDAT = 4\n\n&#039; used memory-sheet\nConst MEM_NAME = 1\nConst MEM_FREE = 2\nConst MEM_TOTAL = 3\nConst MEM_CREATEDAT = 4\n\n&#039; used cpu-sheet\nConst CPU_NAME = 1\nConst CPU_PERSENT = 2\nConst CPU_CREATEDAT = 3\n\n&#039; WMI Object (connect to localhost)\nDim Wmi As Object\n\n&#039; Now datetime\nDim CreatedAt As Date<\/code><\/pre>\n<p><strong><em>Const DISK_NAME = 1<\/em><\/strong><br \/>\n<strong><em>\u3000\u3000\uff1a<\/em><\/strong><br \/>\n<strong><em>Const CPU_CREATEDAT = 3<\/em><\/strong><\/p>\n<p>\u6700\u521d\u306b\u5404\u30b7\u30fc\u30c8\u3067\u4f7f\u3046\u5217\u3092\u5b9a\u6570\uff08<strong><em>Const<\/em><\/strong>\uff09\u3067\u5ba3\u8a00\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3082\u3057\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u4e0a\u3067\u5217\u3092\u8868\u3059\u6570\u5024\u3092\u76f4\u63a5\u66f8\u3044\u3066\u3044\u308b\u3068\u5909\u66f4\u306b\u5f31\u304f\u306a\u308a\u307e\u3059(\u4f8b\u3048\u3070\u5217\u3092\u5165\u308c\u66ff\u3048\u305f\u6642\u306b\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u5909\u66f4\u7b87\u6240\u304c\u591a\u3044\u7b49)\u306e\u3067\u3001\u4e88\u3081\u5b9a\u6570\u3068\u3057\u3066\u5ba3\u8a00\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<p><strong><em>Dim Wmi As Object<\/em><\/strong><br \/>\n\u4eca\u56de\u306f CPU\u3001Memory\u3001Disk \u306e\u5404\u60c5\u5831\u3092 WMI\uff08Windows Management Instrumentation\uff09\u7d4c\u7531\u3067\u53d6\u5f97\u3057\u307e\u3059\u306e\u3067\u3001\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u578b\u3068\u3057\u3066 Wmi \u3092\u5b9a\u7fa9\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><strong><em>Dim CreatedAt As Date<\/em><\/strong><br \/>\nCreatedAt \u306f\u30de\u30af\u30ed\u306e\u5b9f\u884c\u6642\u9593\u3092\u8a18\u9332\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n<hr \/>\n<pre><code class=\"language-vbnet\">&#039;\n&#039; auto running\n&#039;\nSub Workbook_Open()\n    Application.WindowState = xlMinimized\n    Call Logging\nEnd Sub<\/code><\/pre>\n<p>\u30d5\u30a1\u30a4\u30eb(\u30d6\u30c3\u30af)\u3092\u958b\u3044\u305f\u6642\u306b\u30de\u30af\u30ed\u3092\u81ea\u52d5\u5b9f\u884c\u3059\u308b\u30e1\u30bd\u30c3\u30c9\u3067\u3059\u3002<\/p>\n<p><strong><em>Application.WindowState = xlMinimized<\/em><\/strong><br \/>\n\u8d77\u52d5\u6642\u306b\u6700\u5c0f\u5316\u3057\u307e\u3059\u3002<\/p>\n<p><strong><em>Call Logging<\/em><\/strong><br \/>\nLogging \u30b5\u30d6\u30eb\u30fc\u30c1\u30f3\u3092\u547c\u3073\u51fa\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<hr \/>\n<pre><code class=\"language-vbnet\">&#039;\n&#039; main\n&#039;\nPublic Sub Logging()\n    Call Initialize\n    Call SetInfoForCpu\n    Call SetInfoForMemory\n    Call SetInfoForDiskdrive    \n    Call Terminate\nEnd Sub<\/code><\/pre>\n<p>Logging \u30b5\u30d6\u30eb\u30fc\u30c1\u30f3\u3067\u306f\u3001\u6b21\u306e\u51e6\u7406\u3092\u547c\u3073\u51fa\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<ol>\n<li>\u521d\u671f\u5316\u51e6\u7406<\/li>\n<li>CPU \u60c5\u5831\u306e\u53d6\u5f97\u3068\u30b7\u30fc\u30c8\u3078\u306e\u30bb\u30c3\u30c8<\/li>\n<li>Memory \u60c5\u5831\u306e\u53d6\u5f97\u3068\u30b7\u30fc\u30c8\u3078\u306e\u30bb\u30c3\u30c8<\/li>\n<li>Disk \u60c5\u5831\u306e\u53d6\u5f97\u3068\u30b7\u30fc\u30c8\u3078\u306e\u30bb\u30c3\u30c8<\/li>\n<li>\u7d42\u4e86\u51e6\u7406<\/li>\n<\/ol>\n<hr \/>\n<pre><code class=\"language-vbnet\">&#039;\n&#039; Initialize process\n&#039;\nPublic Sub Initialize()        \n    Application.DisplayAlerts = False\n\n    &#039; Set WMI Object\n    Set Wmi = GetObject( _\n        &quot;winmgmts:{impersonationLevel=impersonate}!\\\\.\\root\\cimv2&quot; _\n    )\n\n    &#039; Set Now datatime\n    CreatedAt = Format(Now, &quot;yyyy\/mm\/dd hh:nn:ss&quot;)\nEnd Sub<\/code><\/pre>\n<p><strong><em>Application.DisplayAlerts = False<\/em><\/strong><br \/>\n\u3053\u306e\u3088\u3046\u306a\u8b66\u544a\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u51fa\u3055\u306a\u3044\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\n<a href=\"http:\/\/1bed.allright.life\/wp-content\/uploads\/2016\/10\/alert.png\" data-rel=\"lightbox-image-2\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" src=\"http:\/\/1bed.allright.life\/wp-content\/uploads\/2016\/10\/alert-300x104.png\" alt=\"alert.png\" \/><\/a><\/p>\n<p><strong><em>Set Wmi = GetObject( <em><br \/>\n&quot;winmgmts:{impersonationLevel=impersonate}!\\.\\root\\cimv2&quot; <\/em><br \/>\n)<\/em><\/strong><br \/>\nWMI \u3092\u30ed\u30fc\u30ab\u30eb\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf\u30fc(\u52d5\u4f5c\u3055\u305b\u308b PC)\u306e root\\cimv2 \u540d\u524d\u7a7a\u9593\u306b\u63a5\u7d9a\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\nVBA \u3067\u8907\u6570\u884c\u306b\u5206\u3051\u3066\u66f8\u304d\u305f\u3044\u6642\u306b\u306f\u3001\u4e0a\u8a18\u306e\u3088\u3046\u306b _ (\u30a2\u30f3\u30c0\u30fc\u30b9\u30b3\u30a2)\u3067\u3064\u306a\u3052\u307e\u3059\u3002<\/p>\n<hr \/>\n<pre><code class=\"language-vbnet\">&#039;\n&#039; Terminate process\n&#039;\nPublic Sub Terminate()\n\n    Set Wmi = Nothing\n    ThisWorkbook.Save\n    If Workbooks.Count = 1 Then\n        Application.Quit\n    Else\n        ThisWorkbook.Close\n    End If\nEnd Sub<\/code><\/pre>\n<p>\u7d42\u4e86\u51e6\u7406\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><strong><em>Set Wmi = Nothing<\/em><\/strong><br \/>\nWmi \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u7834\u68c4\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n<p><strong><em>ThisWorkbook.Save<\/em><\/strong><br \/>\n\u30d5\u30a1\u30a4\u30eb\u306e\u4fdd\u5b58\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n<p><strong><em>If Workbooks.Count = 1 Then<br \/>\nApplication.Quit<br \/>\nElse<br \/>\nThisWorkbook.Close<br \/>\nEnd If<\/em><\/strong><br \/>\n\u4ed6\u306e Excel \u30d5\u30a1\u30a4\u30eb\u304c\u958b\u304b\u308c\u3066\u3044\u306a\u3044\u6642\u306b Excel \u306e\u7d42\u4e86\uff08<strong><em>Application.Quit<\/em><\/strong>\uff09\u3001\u4ed6\u306b\u958b\u3044\u3066\u3044\u308b Excel \u304c\u3042\u308b\u6642\u306b\u306f\u4eca\u306e\u30d5\u30a1\u30a4\u30eb\u3060\u3051\u9589\u3058\u3066\u3044\u307e\u3059\uff08<strong><em>ThisWorkbook.Close<\/em><\/strong>\uff09\u3002<\/p>\n<hr \/>\n<pre><code class=\"language-vbnet\">&#039;\n&#039; Set cpu information to Datasheet\n&#039;\nPublic Sub SetInfoForCpu()\n    Dim Sheet As Worksheet: Set Sheet = ThisWorkbook.Worksheets(&quot;cpu&quot;)\n    Dim Row As Long: Row = Sheet.Cells(Rows.Count, CPU_NAME).End(xlUp).Row + 1\n\n    Dim Items As Object: Set Items = Wmi.ExecQuery(&quot;SELECT * FROM Win32_PerfFormattedData_PerfOS_Processor&quot;)\n    Dim Item As Object\n\n    For Each Item In Items\n        If Item.Name &lt;&gt; &quot;&quot; Then\n            Sheet.Cells(Row, CPU_NAME).Value = Item.Name\n            Sheet.Cells(Row, CPU_PERSENT).Value = Item.PercentProcessorTime\n            Sheet.Cells(Row, CPU_CREATEDAT).Value = CreatedAt\n            Row = Row + 1\n        End If\n    Next\n\n    Set Item = Nothing\n    Set Items = Nothing\n    Set Sheet = Nothing\nEnd Sub<\/code><\/pre>\n<p>SetInfoForCpu \u306f CPU \u60c5\u5831\u306e\u53d6\u5f97\u3068\u30b7\u30fc\u30c8\u3078\u306e\u30bb\u30c3\u30c8\u3092\u884c\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><strong><em>Row = Sheet.Cells(Rows.Count, CPU_NAME).End(xlUp).Row + 1<\/em><\/strong><br \/>\n\u30c7\u30fc\u30bf\u3092\u8a18\u9332\u3067\u304d\u308b\u884c\u3092\u53d6\u5f97\u3059\u308b\u305f\u3081\u3001\u300c\u30c7\u30fc\u30bf\u306e\u3042\u308b\u6b21\u306e\u884c\u300d\u3092 Row \u306b\u30bb\u30c3\u30c8\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u305d\u306e\u5f8c WMI \u304b\u3089\u53d6\u5f97\u3057\u305f\u30c7\u30fc\u30bf\u3092 Cell \u306b\u30bb\u30c3\u30c8\u3057\u3066\u3044\u304d\u3001\u6700\u5f8c\u306b\u4f7f\u7528\u3057\u305f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u7834\u68c4\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<hr \/>\n<pre><code class=\"language-vbnet\">&#039;\n&#039; Set memory information to Datasheet\n&#039;\nPublic Sub SetInfoForMemory()\n    Dim Sheet As Worksheet: Set Sheet = ThisWorkbook.Worksheets(&quot;memory&quot;)\n    Dim Row As Long: Row = Sheet.Cells(Rows.Count, MEM_NAME).End(xlUp).Row + 1\n\n    Dim Items As Object: Set Items = Wmi.ExecQuery(&quot;SELECT * FROM Win32_OperatingSystem&quot;)\n    Dim Item As Object\n\n    For Each Item In Items\n        If Item.FreePhysicalMemory &lt;&gt; &quot;&quot; Then\n            Sheet.Cells(Row, MEM_NAME).Value = &quot;PhysicalMemory&quot;\n            Sheet.Cells(Row, MEM_FREE).Value = Item.FreePhysicalMemory\n            Sheet.Cells(Row, MEM_TOTAL).Value = Item.TotalVisibleMemorySize\n            Sheet.Cells(Row, MEM_CREATEDAT).Value = CreatedAt\n            Row = Row + 1\n        End If\n\n        If Item.FreeVirtualMemory &lt;&gt; &quot;&quot; Then\n            Sheet.Cells(Row, MEM_NAME).Value = &quot;VirtualMemory&quot;\n            Sheet.Cells(Row, MEM_FREE).Value = Item.FreeVirtualMemory\n            Sheet.Cells(Row, MEM_TOTAL).Value = Item.TotalVirtualMemorySize\n            Sheet.Cells(Row, MEM_CREATEDAT).Value = CreatedAt\n            Row = Row + 1\n        End If\n    Next\n\n    Set Item = Nothing\n    Set Items = Nothing\n    Set Sheet = Nothing\nEnd Sub<\/code><\/pre>\n<p>SetInfoForMemory \u306f Memory \u60c5\u5831\u306e\u53d6\u5f97\u3068\u30b7\u30fc\u30c8\u3078\u306e\u30bb\u30c3\u30c8\u3092\u884c\u3063\u3066\u3044\u307e\u3059\u3002<br \/>\nMemory \u306b\u306f\u300c\u7269\u7406\u30e1\u30e2\u30ea\u300d\u3068\u300c\u4eee\u60f3\u30e1\u30e2\u30ea(swap)\u300d\u304c\u3042\u308a\u3001\u7269\u7406\u30e1\u30e2\u30ea\u3092 PhysicalMemory\u3001\u4eee\u60f3\u30e1\u30e2\u30ea\u3092 VirtualMemory \u3068\u3057\u3066\u30c7\u30fc\u30bf\u3092\u30bb\u30c3\u30c8\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<hr \/>\n<pre><code class=\"language-vbnet\">&#039;\n&#039; Set diskdrive information to Datasheet\n&#039;\nPublic Sub SetInfoForDiskdrive()\n\n    Dim Sheet As Worksheet: Set Sheet = ThisWorkbook.Worksheets(&quot;disk&quot;)\n    Dim Row As Long: Row = Sheet.Cells(Rows.Count, DISK_NAME).End(xlUp).Row + 1\n\n    Dim Items As Object: Set Items = Wmi.ExecQuery(&quot;SELECT * FROM Win32_LogicalDisk&quot;)\n    Dim Item As Object\n\n    For Each Item In Items\n        If Item.DeviceID &lt;&gt; &quot;&quot; Then\n            Sheet.Cells(Row, DISK_NAME).Value = Item.DeviceID\n            Sheet.Cells(Row, DISK_FREE).Value = Item.FreeSpace\n            Sheet.Cells(Row, DISK_TOTAL).Value = Item.Size\n            Sheet.Cells(Row, DISK_CREATEDAT).Value = CreatedAt\n            Row = Row + 1\n        End If\n    Next\n\n    Set Item = Nothing\n    Set Items = Nothing\n    Set Sheet = Nothing\nEnd Sub<\/code><\/pre>\n<p>Disk \u60c5\u5831\u306e\u53d6\u5f97\u3068\u30b7\u30fc\u30c8\u3078\u306e\u30bb\u30c3\u30c8\u306f CPU \u3068 Memory \u306e\u6642\u3068\u307b\u307c\u540c\u3058\u3067\u3059\u3002<\/p>\n<h2>1-3. \u30de\u30af\u30ed\u306e\u4fdd\u5b58<\/h2>\n<p>\u540d\u524d\u3092\u3064\u3051\u3066\u4fdd\u5b58\u3092\u884c\u3044\u3001\u30d5\u30a1\u30a4\u30eb\u306e\u7a2e\u985e\u3092 *<em>Excel \u30de\u30af\u30ed\u6709\u52b9\u30d6\u30c3\u30af(<\/em>.xlsm)** \u3092\u9078\u629e\u3057\u3066\u4fdd\u5b58\u3057\u307e\u3059\u3002<br \/>\n<a href=\"https:\/\/github.com\/miyamiya\/Learnning_ExcelMacro\/blob\/master\/MachinePerformance\/performance.xlsm\">\u3053\u3053\u3067\u4f5c\u6210\u3055\u308c\u305f Excel \u30d5\u30a1\u30a4\u30eb\u306f\u3053\u3061\u3089\u306b\u306a\u308a\u307e\u3059 &gt;&gt; performance.xlsm<\/a><\/p>\n<h1>2. \u30bf\u30b9\u30af\u30b9\u30b1\u30b8\u30e5\u30fc\u30e9\u30fc\u3078\u306e\u8a2d\u5b9a<\/h1>\n<p>\u30bf\u30b9\u30af\u30b9\u30b1\u30b8\u30e5\u30fc\u30e9\u30fc\u3078\u306e\u8a2d\u5b9a\u3092\u8a66\u307f\u307e\u3057\u305f\u304c\u4e0a\u624b\u304f\u52d5\u3044\u3066\u304f\u308c\u305a\u3001\u8abf\u3079\u308b\u3068\u5168\u304f\u540c\u3058\u72b6\u614b\u3067\u30d6\u30ed\u30b0\u306b\u60c5\u5831\u3092\u8f09\u305b\u3066\u304f\u3060\u3055\u3063\u3066\u3044\u308b\u65b9\u304c\u3044\u307e\u3057\u305f\u3002\u3042\u308a\u304c\u3068\u3046\u3054\u3056\u3044\u307e\u3059\uff01<\/p>\n<ul>\n<li>\n<p><a href=\"http:\/\/n-portal.com\/system\/task_scheduler\">Windows10\u306e\u30bf\u30b9\u30af\u30b9\u30b1\u30b8\u30e5\u30fc\u30e9\u3067\u8a2d\u5b9a\u3057\u305f\u7e70\u308a\u8fd4\u3057\u51e6\u7406\u304c\u8d77\u52d5\u3057\u306a\u3044<\/a><br \/>\n\u30dd\u30a4\u30f3\u30c8\u306f\u6b21\u306e\u901a\u308a<\/p>\n<ul>\n<li>\u30e6\u30fc\u30b6\u30fc\u304c\u30ed\u30b0\u30aa\u30f3\u3057\u3066\u3044\u308b\u3068\u304d\u306e\u307f\u5b9f\u884c\u3059\u308b<\/li>\n<li>\u8a2d\u5b9a\u3092 1 \u56de\u3001\u7e70\u308a\u8fd4\u3057\u9593\u9694\u3092\u8a2d\u5b9a\u3001\u7d99\u7d9a\u6642\u9593\u3092\u7121\u671f\u9650\u306b\u3059\u308b<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u3053\u308c\u3089\u3092\u8e0f\u307e\u3048\u3066\u8a2d\u5b9a\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<h2>2-1. \u30bf\u30b9\u30af\u30b9\u30b1\u30b8\u30e5\u30fc\u30e9\u306e\u8d77\u52d5<\/h2>\n<p>\u30bf\u30b9\u30af\u30b9\u30b1\u30b8\u30e5\u30fc\u30e9\u3092\u8d77\u52d5\u3057\u307e\u3059\u3002<br \/>\nCortana \u306b\u300c\u30bf\u30b9\u30af\u300d\u3068\u5165\u529b\u3057\u305f\u3089\u51fa\u3066\u304f\u308b\u3068\u601d\u3044\u307e\u3059\u3002<br \/>\n<a href=\"http:\/\/1bed.allright.life\/wp-content\/uploads\/2016\/10\/4.png\" data-rel=\"lightbox-image-3\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" src=\"http:\/\/1bed.allright.life\/wp-content\/uploads\/2016\/10\/4-189x300.png\" alt=\"\" \/><\/a><\/p>\n<h2>2-2. \u8a2d\u5b9a<\/h2>\n<ul>\n<li>\u64cd\u4f5c\u306e <strong>\u30bf\u30b9\u30af\u306e\u4f5c\u6210<\/strong> \u3092\u30af\u30ea\u30c3\u30af\u3057\u307e\u3059\u3002<br \/>\n<a href=\"http:\/\/1bed.allright.life\/wp-content\/uploads\/2016\/10\/5.png\" data-rel=\"lightbox-image-4\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" src=\"http:\/\/1bed.allright.life\/wp-content\/uploads\/2016\/10\/5.png\" alt=\"\" \/><\/a><\/li>\n<\/ul>\n<p>\u3000<\/p>\n<ul>\n<li>\u4efb\u610f\u306e\u540d\u524d\u3092\u5165\u529b<\/li>\n<li><strong>\u30e6\u30fc\u30b6\u30fc\u304c\u30ed\u30b0\u30aa\u30f3\u3057\u3066\u3044\u308b\u3068\u304d\u306e\u307f\u5b9f\u884c\u3059\u308b<\/strong> \u3092\u9078\u629e<br \/>\n<a href=\"http:\/\/1bed.allright.life\/wp-content\/uploads\/2016\/10\/6.png\" data-rel=\"lightbox-image-5\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" src=\"http:\/\/1bed.allright.life\/wp-content\/uploads\/2016\/10\/6-300x216.png\" alt=\"\" \/><\/a><\/li>\n<\/ul>\n<p>\u3000<\/p>\n<ul>\n<li>\u8a2d\u5b9a\u3092 1 \u56de<\/li>\n<li>\u7e70\u308a\u8fd4\u3057\u9593\u9694\u3092\u4efb\u610f\u306e\u9593\u9694\u3067\u5165\u529b<\/li>\n<li>\u7d99\u7d9a\u6642\u9593\u306f\u7121\u671f\u9650\u3092\u9078\u629e<br \/>\n<a href=\"http:\/\/1bed.allright.life\/wp-content\/uploads\/2016\/10\/7.png\" data-rel=\"lightbox-image-6\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" src=\"http:\/\/1bed.allright.life\/wp-content\/uploads\/2016\/10\/7-300x255.png\" alt=\"\" \/><\/a><\/li>\n<\/ul>\n<p>\u3000<\/p>\n<ul>\n<li>\u30d7\u30ed\u30b0\u30e9\u30e0\/\u30b9\u30af\u30ea\u30d7\u30c8\u306b\u6b21\u306e\u5024\u3092\u5165\u529b<br \/>\n<em>&quot;C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\EXCEL.EXE&quot;<\/em><\/li>\n<li>\n<p>\u5f15\u6570\u306e\u8ffd\u52a0(\u30aa\u30d7\u30b7\u30e7\u30f3) \u306b\u6b21\u306e\u5024\u3092\u5165\u529b<br \/>\n&lt;\u30de\u30af\u30ed\u6709\u52b9\u30d6\u30c3\u30af\u306e\u7d76\u5bfe\u30d1\u30b9&gt; \/e<\/p>\n<ul>\n<li>\u4f8b: C:\\Users\\hoge\\Desktop\\performance.xlsm \/e<br \/>\n<a href=\"http:\/\/1bed.allright.life\/wp-content\/uploads\/2016\/10\/8.png\" data-rel=\"lightbox-image-7\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" src=\"http:\/\/1bed.allright.life\/wp-content\/uploads\/2016\/10\/8-272x300.png\" alt=\"\" \/><\/a><\/li>\n<\/ul>\n<p>\/e \u3092\u4ed8\u3051\u308b\u3053\u3068\u3067\u3001Excel \u306e\u8d77\u52d5\u753b\u9762\u304c\u8868\u793a\u3055\u308c\u307e\u305b\u3093\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u8a2d\u5b9a\u306f\u4ee5\u4e0a\u3067\u3059\u306e\u3067\u3001OK \u3067\u30bf\u30b9\u30af\u306e\u4f5c\u6210\u3092\u5b8c\u4e86\u3055\u305b\u3066\u4e0b\u3055\u3044\u3002<\/p>\n<h2>3. \u5b9f\u884c<\/h2>\n<p>\u30c6\u30b9\u30c8\u5b9f\u884c\u3059\u308b\u6642\u306b\u306f\u3001\u767b\u9332\u3057\u305f\u30bf\u30b9\u30af\u3092\u53f3\u30af\u30ea\u30c3\u30af\u3057\u3066\u300c\u5b9f\u884c\u3059\u308b\u300d\u3092\u9078\u629e\u3059\u308b\u3068\u5b9f\u884c\u3055\u308c\u307e\u3059\u3002<br \/>\n\u305d\u306e\u969b\u3001 <strong>\u521d\u56de\u306e\u5b9f\u884c\u306e\u6642\u306b\u30de\u30af\u30ed\u306e\u8b66\u544a\u304c\u3067\u307e\u3059\u306e\u3067\u8a31\u53ef\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/strong><\/p>\n<p>\u4eca\u56de\u4f5c\u6210\u3057\u305f\u30de\u30af\u30ed\u306f\u3001\u8d77\u52d5\u3059\u308b\u3068\u81ea\u52d5\u3067\u5b9f\u884c\u3057\u3066\u9589\u3058\u3066\u3057\u307e\u3044\u307e\u3059\u306e\u3067\u3001\u4e2d\u306e\u30c7\u30fc\u30bf\u3092\u78ba\u8a8d\u3059\u308b\u6642\u306f\u30de\u30af\u30ed\u304c\u52d5\u304b\u306a\u3044\u3088\u3046\u306b\u958b\u304f\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<ol>\n<li>Excel \u3092\u958b\u304f (\u30d5\u30a1\u30a4\u30eb\u3092\u30c0\u30d6\u30eb\u30af\u30ea\u30c3\u30af\u3067\u306f\u306a\u3044)<\/li>\n<li>\u30d5\u30a1\u30a4\u30eb\u3092\u958b\u304f\u6642\u306b Shift \u30dc\u30bf\u30f3\u3092\u62bc\u3057\u306a\u304c\u3089\u958b\u304f<\/li>\n<\/ol>\n<p><a href=\"http:\/\/1bed.allright.life\/wp-content\/uploads\/2016\/10\/10-1.png\" data-rel=\"lightbox-image-8\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" src=\"http:\/\/1bed.allright.life\/wp-content\/uploads\/2016\/10\/10-1-300x209.png\" alt=\"10-1.png\" \/><\/a><\/p>\n<p><a href=\"http:\/\/1bed.allright.life\/wp-content\/uploads\/2016\/10\/10-2.png\" data-rel=\"lightbox-image-9\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" src=\"http:\/\/1bed.allright.life\/wp-content\/uploads\/2016\/10\/10-2-300x190.png\" alt=\"10-2.png\" \/><\/a><\/p>\n<h1>\u8003\u5bdf<\/h1>\n<p>Windows Server 2008 R2 \u3067\u3059\u3093\u306a\u308a\u4e0a\u624b\u304f\u884c\u3063\u3066\u3044\u305f\u30bf\u30b9\u30af\u30b9\u30b1\u30b8\u30e5\u30fc\u30e9\u306e\u8a2d\u5b9a\u304c\u3001Windows 10 \u3067\u52d5\u4f5c\u304c\u5909\u308f\u3063\u3066\u3044\u308b\u3053\u3068\u306b\u6c17\u4ed8\u304f\u306e\u306b 2 \u6642\u9593\u304b\u304b\u3063\u3066\u30cf\u30de\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>\u5b9f\u969b\u306b\u4f7f\u3046\u6642\u306b\u306f\u3001\u30b0\u30e9\u30d5\u5316\u3057\u3084\u3059\u3044\u3088\u3046\u306b\u30c7\u30fc\u30bf\u3092\u53d6\u3063\u305f\u65b9\u304c\u826f\u3044\u3067\u3059\u306d\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Excel \u30de\u30af\u30ed\u306f\u30bf\u30b9\u30af\u30b9\u30b1\u30b8\u30e5\u30fc\u30e9\u3067\u5b9f\u884c\u3067\u304d\u308b\u306e\u304b PowerShell \u3067\u30ed\u30b0\u53ce\u96c6\u30fb\u7cbe\u67fb\u3092\u3057\u3066\u3001\u78ba\u8a8d\u7528\u306e Excel \u306b\u4fdd\u5b58\u3059\u308b\u3002 \u300cExcel \u304c\u81ea\u5206\u81ea\u8eab\u3067\u3084\u308c\u3088\u300d\u3068\u8003\u3048\u3066\u3057\u307e\u3044\u3001\u300c\u305d\u3082\u305d\u3082 Excel \u306e\u30de\u30af\u30ed [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[97,96],"class_list":["post-2300","post","type-post","status-publish","format-standard","hentry","category-program","tag-excel","tag-vba"],"_links":{"self":[{"href":"https:\/\/1bed.allright.life\/index.php?rest_route=\/wp\/v2\/posts\/2300","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/1bed.allright.life\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/1bed.allright.life\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/1bed.allright.life\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/1bed.allright.life\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2300"}],"version-history":[{"count":10,"href":"https:\/\/1bed.allright.life\/index.php?rest_route=\/wp\/v2\/posts\/2300\/revisions"}],"predecessor-version":[{"id":3141,"href":"https:\/\/1bed.allright.life\/index.php?rest_route=\/wp\/v2\/posts\/2300\/revisions\/3141"}],"wp:attachment":[{"href":"https:\/\/1bed.allright.life\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2300"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/1bed.allright.life\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2300"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/1bed.allright.life\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2300"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}