{"id":1907,"date":"2020-09-04T06:00:26","date_gmt":"2020-09-03T21:00:26","guid":{"rendered":"https:\/\/qol-kk.com\/wp2\/?p=1907"},"modified":"2020-09-04T11:56:05","modified_gmt":"2020-09-04T02:56:05","slug":"post-1907","status":"publish","type":"post","link":"https:\/\/qol-kk.com\/wp2\/blog\/2020\/09\/04\/post-1907\/","title":{"rendered":"VBS\u3067\u7c21\u5358\u306bCSV\u3092\u8aad\u307f\u8fbc\u3080\u65b9\u6cd5\uff08CSV\u3092\u5c0f\u3055\u3044DB\u3068\u3057\u3066\u5229\u7528\u3059\u308b\u65b9\u6cd5\uff09"},"content":{"rendered":"<h2>VBS\u3067\u7c21\u5358\u306bCSV\u3092\u8aad\u307f\u8fbc\u3080\u65b9\u6cd5\uff08CSV\u3092\u5c0f\u3055\u3044DB\u3068\u3057\u3066\u5229\u7528\u3059\u308b\u65b9\u6cd5\uff09<\/h2>\n<p>EC\u30e2\u30fc\u30eb\u3078\u306e\u30a2\u30af\u30bb\u30b9\u3092\u69cb\u7bc9\u3057\u3088\u3046\u3068\u3059\u308b\u3068\u3001\u3069\u3046\u3057\u3066\u3082ID\u3068PASS\u306e\u30ea\u30b9\u30c8\u304c\u5fc5\u8981\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\nExcelVBA\u3067\u5b9f\u88c5\u3057\u3066\u3044\u308b\u5834\u5408\u306fExcel\u306e\u4e2d\u306b\u66f8\u3051\u3070\u3044\u3044\u3067\u3059\u304c\u3001VBS\u306e\u5834\u5408\u30d9\u30fc\u30b9\u3068\u306a\u308bExcel\u306f\u6a19\u6e96\u88c5\u5099\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002\u305d\u306e\u70ba\u3001CSV\u30c7\u30fc\u30bf\u3092\u7c21\u6613DB\u3068\u3057\u3066\u6d3b\u7528\u3059\u308b\u4e8b\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u305d\u3093\u306a\u65b9\u6cd5\u3092\u5099\u5fd8\u9332\u3068\u3057\u3066\u8a18\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<h3>CSV\u3092\u8aad\u307f\u8fbc\u3080\u30b3\u30fc\u30c9<\/h3>\n<pre class=\"lang:default decode:true\">Option Explicit\r\n  Dim objFso\r\n  Dim filePath\r\n  Dim objFile\r\n  Dim aryRet()\r\n  Dim i\r\n  Dim objWshShell\r\n  Dim aryStrings\r\n  Dim objMall\r\n  \r\n  Set objFso = WScript.CreateObject(\"Scripting.FileSystemObject\")\r\n  Set objWshShell = WScript.CreateObject(\"WScript.Shell\")\r\n\r\n  '\u30d5\u30a1\u30a4\u30eb\u306e\u76f8\u5bfe\u30d1\u30b9\u203b\u7d76\u5bfe\u30d1\u30b9\u3067\u3082\u3082\u3061\u308d\u3093OK\r\n  filePath = \"\\..\\hogeDB.csv\"\r\n  Set objFile = objFso.OpenTextFile(objWshShell.CurrentDirectory &amp; filePath )\r\n\t\r\n  If Err.Number = 0 Then\r\n    '\u30eb\u30fc\u30d7\u30ab\u30a6\u30f3\u30bf\u306e\u521d\u671f\u5316\r\n    i = 0\r\n    '\u30d5\u30a1\u30a4\u30eb\u306e\u5185\u5bb9\u30921\u884c\u305a\u3064\u914d\u5217\u306b\u683c\u7d0d\r\n    Do Until objFile.AtEndOfStream\r\n      '\u4e2d\u8eab\u3092\u4fdd\u3063\u305f\u307e\u307e\u914d\u5217\u306e\u5927\u304d\u3055\u3092\u62e1\u5f35\r\n      redim Preserve aryRet(i)\r\n      '1\u884c\u8aad\u307f\u8fbc\u3093\u3067\u914d\u5217\u306b\u683c\u7d0d\r\n      aryRet(i) = objFile.ReadLine\r\n      '\u30ab\u30a6\u30f3\u30bf\u5897\u52a0\r\n      i = i + 1\r\n    Loop\r\n\r\n    '\u30d5\u30a1\u30a4\u30eb\u3092\u30af\u30ed\u30fc\u30ba\r\n    objFile.Close\r\n  Else\r\n    '\u30a8\u30e9\u30fc\u306e\u5185\u5bb9(Description)\u51fa\u529b\r\n    WScript.Echo \"\u30d5\u30a1\u30a4\u30eb\u304c\u958b\u3051\u307e\u305b\u3093: \" &amp; Err.Description\r\n  End If<\/pre>\n<p>CSV\u3092\u8aad\u307f\u8fbc\u3080\u3046\u3048\u3067\u5fc5\u9808\u306a\u3082\u306e\u306f\u884c\u6570\u306e\u7ba1\u7406\u3067\u3059\u3002<br \/>\n\u3067\u3082VBS\u306f\u30a4\u30f3\u30af\u30ea\u30e1\u30f3\u30bf\u30eb\u6f14\u7b97\u5b50\u3092\u6301\u305f\u306a\u3044\u306e\u3067\u300e i++ \u300f\u306e\u547d\u4ee4\u306f\u4f7f\u3048\u306a\u3044\u306e\u3067\u300ei = i + 1\u300f\u3067\u30ab\u30a6\u30f3\u30c8\u3092\u5897\u3084\u3057\u307e\u3059\u3002<\/p>\n<h3>CSV\u306e\u8aad\u307e\u305b\u65b9<\/h3>\n<p>\u6bb5\u53d6\u308a\u3068\u3057\u3066\u306f\u3053\u3093\u306a\u611f\u3058\u3067\u3059\u3002<\/p>\n<div class=\"paperBox\">\n<ol>\n<li>\u8aad\u307f\u8fbc\u307f\u305f\u3044CSV\u30d5\u30a1\u30a4\u30eb\u3092\u6307\u793a\u3057\u3066\u3010 OpenTextFile \u3011\u3067\u30d5\u30a1\u30a4\u30eb\u3092\u958b\u304f<\/li>\n<li>\u8aad\u307f\u8fbc\u3080\u884c\u6570\u3092\u683c\u7d0d\u3059\u308b\u5909\u6570\u3092\u7528\u610f\u3002\u203b\u5148\u982d\u304b\u30893\u884c\u98db\u3070\u3057\u305f\u3044\u5834\u5408\u306f i = 2 \u304b\u3089\u59cb\u3081\u308c\u3070\u3088\u3044<\/li>\n<li>1\u884c\u305a\u3064\u914d\u5217\u306b\u683c\u7d0d\u3059\u308b\u3002 \u203b\u3053\u306e\u6642\u70b9\u3067\u914d\u5217\u306b\u306f\u30ab\u30f3\u30de\u533a\u5207\u308a\u306e\u30ec\u30b3\u30fc\u30c9\u304c\u884c\u3054\u3068\u306b\u5206\u3051\u3089\u308c\u3066\u683c\u7d0d\u3055\u308c\u3066\u3044\u308b<\/li>\n<li>\u4f5c\u6210\u3057\u305f\u914d\u5217\u30921\u30ec\u30b3\u30fc\u30c9\u3065\u3064\u8aad\u8fbc\u307f\u30ab\u30e9\u30e0\u3092\u5206\u3051\u308b<\/li>\n<li>\u76ee\u7684\u306e\u30ab\u30e9\u30e0\u756a\u53f7\u3092\u6307\u793a\u3057\u3066\u76ee\u7684\u306e\u5024\u3092\u53d6\u5f97\u3059\u308b<\/li>\n<\/ol>\n<\/div>\n<p>\u4e0a\u306e\u9805\u3067\u8a18\u8f09\u3057\u305f\u30b3\u30fc\u30c9\u30922\u56de\u8ee2\u3059\u308b\u30a4\u30e1\u30fc\u30b8\u3067\u3059\u3002<\/p>\n<p>\u30d5\u30a1\u30a4\u30eb\u306e\u8aad\u307f\u8fbc\u307f\u81ea\u4f53\u306f\u3010 Set objFile = objFso.OpenTextFile(objWshShell.CurrentDirectory &amp; filePath ) \u3011\u3067OK\u3002<br \/>\n\u3053\u308c\u3092\u3010 Do Until objFile.AtEndOfStream ~~~~~ Loop \u3011\u306b\u304b\u3051\u3010 aryRet(i) = objFile.ReadLine \u3011\u30671\u30ec\u30b3\u30fc\u30c9\u305a\u3064\u53d6\u308a\u51fa\u3057\u307e\u3059\u3002<\/p>\n<p>1\u56de\u8ee2\u76ee\u3067\u30ab\u30f3\u30de\u533a\u5207\u308a\u30ec\u30b3\u30fc\u30c9\u306e\u914d\u5217\u304c\u51fa\u6765\u4e0a\u304c\u308a\u30012\u56de\u8ee2\u76ee\u3067\u305d\u308c\u3092\u5206\u89e3\u3057\u305f\u30ab\u30e9\u30e0\u3092\u4f5c\u6210\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<h3>\u307e\u3068\u3081<\/h3>\n<p>\u3053\u3053\u3089\u8fba\u306f\u3044\u308d\u3093\u306a\u30b5\u30a4\u30c8\u3055\u3093\u3067\u5b9f\u88c5\u65b9\u6cd5\u304c\u8a18\u8f09\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u3068\u3066\u3082\u52c9\u5f37\u306b\u306a\u308a\u307e\u3059\u3057\u3001\u3042\u307e\u308a\u82e6\u306b\u306a\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u307e\u305f\u3001\u30ec\u30b3\u30fc\u30c9\u306e\u53d6\u308a\u6271\u3044\u65b9\u3068\u3057\u3066\u6700\u521d\u306e\u8aad\u307f\u8fbc\u307f\u6642\u306b\u591a\u6b21\u5143\u914d\u5217\u3092\u4f5c\u6210\u3057\u3066\u3057\u307e\u3046\u65b9\u6cd5\u3082\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u305f\u3060\u3001\u500b\u4eba\u7684\u306b\u300e\u30ab\u30f3\u30de\u533a\u5207\u308a\u30ec\u30b3\u30fc\u30c9\u3068\u3057\u3066\u683c\u7d0d\u3057\u3066\u304a\u3044\u3066\u5229\u7528\u3059\u308b\u3068\u304d\u306b\u8a73\u7d30\u3092\u5206\u3051\u308b\u300f\u65b9\u304c\u53d6\u308a\u6271\u3044\u304c\u697d\u3060\u3068\u611f\u3058\u3066\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>VBS\u3067\u7c21\u5358\u306bCSV\u3092\u8aad\u307f\u8fbc\u3080\u65b9\u6cd5\uff08CSV\u3092\u5c0f\u3055\u3044DB\u3068\u3057\u3066\u5229\u7528\u3059\u308b\u65b9\u6cd5\uff09 EC\u30e2\u30fc\u30eb\u3078\u306e\u30a2\u30af\u30bb\u30b9\u3092\u69cb\u7bc9\u3057\u3088\u3046\u3068\u3059\u308b\u3068\u3001\u3069\u3046\u3057\u3066\u3082ID\u3068PASS\u306e\u30ea\u30b9\u30c8\u304c\u5fc5\u8981\u306b\u306a\u308a\u307e\u3059\u3002 ExcelVBA\u3067\u5b9f\u88c5\u3057\u3066\u3044\u308b\u5834\u5408\u306fExcel\u306e [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1923,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"sns_share_botton_hide":"","vkExUnit_sns_title":"","_vk_print_noindex":"","sitemap_hide":"","_veu_custom_css":"","veu_display_promotion_alert":"","vkexunit_cta_each_option":"","_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","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},"jetpack_post_was_ever_published":false},"categories":[689],"tags":[709,685,145,684,53,67,68],"class_list":["post-1907","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wsh-vbs","tag-csv","tag-vbs","tag-windows10","tag-wsh","tag-53","tag-67","tag-68"],"veu_head_title_object":{"title":"","add_site_title":""},"jetpack_publicize_connections":[],"jetpack-related-posts":[],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/qol-kk.com\/wp2\/wp-content\/uploads\/2020\/09\/image.png","_links":{"self":[{"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/posts\/1907","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/comments?post=1907"}],"version-history":[{"count":0,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/posts\/1907\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/media\/1923"}],"wp:attachment":[{"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/media?parent=1907"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/categories?post=1907"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/tags?post=1907"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}