{"id":918,"date":"2021-06-10T13:11:39","date_gmt":"2021-06-10T04:11:39","guid":{"rendered":"https:\/\/sunafukin.jp\/?p=918"},"modified":"2021-06-30T09:30:37","modified_gmt":"2021-06-30T00:30:37","slug":"vbaexcel%e3%81%8b%e3%82%89access%e3%81%ae%e3%82%a2%e3%82%af%e3%82%b7%e3%83%a7%e3%83%b3%e3%82%af%e3%82%a8%e3%83%aa%e3%82%92%e5%ae%9f%e8%a1%8c%e3%81%97%e3%80%81%e3%82%bb%e3%83%ab%e3%81%ab%e3%82%b3","status":"publish","type":"post","link":"https:\/\/sunafukin.jp\/?p=918","title":{"rendered":"VBA:Excel\u304b\u3089Access\u306e\u30a2\u30af\u30b7\u30e7\u30f3\u30af\u30a8\u30ea\u3092\u5b9f\u884c\u3057\u3001\u30bb\u30eb\u306b\u30b3\u30d4\u30fc\u3059\u308b"},"content":{"rendered":"<h2>Excel VBA\u3067Access\u306e\u30a2\u30af\u30b7\u30e7\u30f3\u30af\u30a8\u30ea\u3092\u5b9f\u884c\u3057\u3001\u30bb\u30eb\u306b\u30b3\u30d4\u30fc\u3059\u308b<\/h2>\n<p>\u81ea\u52d5\u5316\u3092\u884c\u3046\u306b\u3042\u305f\u308a\u3001Access\u306e\u30a2\u30af\u30b7\u30e7\u30f3\u30af\u30a8\u30ea\u3092Excel VBA\u3092\u5229\u7528\u3057\u3066\u5b9f\u884c\u3059\u308b\u6a5f\u4f1a\u304c\u3042\u3063\u305f\u306e\u3067\u8abf\u67fb\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>VBA\u3092\u5b9f\u884c\u3059\u308b\u524d\u306b\u3001\u300cMicrosoft ActiveX Data Objects 6.1 Libraly\u300d\u307e\u305f\u306f\u300cMicrosoft ActiveX Data Objects 2.X Libraly\u300d\u3092\u53c2\u7167\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<p>\u53c2\u7167\u8a2d\u5b9a\u306b\u3064\u3044\u3066\u306f\u3001\u4ee5\u4e0b\u3067\u8aac\u660e\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\r\n\t\t\t<div class=\"sitecard\">\r\n\t\t\t\t<div class=\"sitecard__subtitle\">\u95a2\u9023\u8a18\u4e8b<\/div>\r\n\t\t\t\t<div class=\"sitecard__contents\">\r\n\t\t\t\t\t<div class=\"heading heading-secondary\"><a href=\"https:\/\/sunafukin.jp\/?p=662#outline_1__3_1\" target=\"__blank\">VBA:\u4e8b\u524d\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u3068\u5b9f\u884c\u6642\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u306e\u9055\u3044<\/a><\/div>\r\n\t\t\t\t\t<p class=\"phrase phrase-tertiary\">\u4e8b\u524d\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u3068\u5b9f\u884c\u6642\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u306e\u9055\u3044\r\nVBA\u306e\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u3068\u306f\u3001\u5916\u90e8\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u6a5f\u80fd\u3092VBA\u3067\u5229\u7528\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b\u3053\u3068\u3067\u3059\u3002\r\n\r\n\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u306f2\u901a\u308a\u306e\u65b9\u6cd5\u304c\u3042\u308a\u3001\u5b9f\u884c\u6642\u306b\u5229\u7528\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b\u5b9f\u884c\u6642\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0(\u9045\u5ef6[\u2026]<\/p>\r\n\t\t\t\t<\/div>\r\n\t\t\t\t<div class=\"eyecatch eyecatch-11\"><a class=\"eyecatch__link eyecatch__link-zoomgray\" href=\"https:\/\/sunafukin.jp\/?p=662#outline_1__3_1\" target=\"__blank\"><img decoding=\"async\" width=\"375\" height=\"250\" src=\"https:\/\/sunafukin.jp\/wp-content\/themes\/the-thor\/img\/dummy.gif\" data-layzr=\"https:\/\/sunafukin.jp\/wp-content\/uploads\/2021\/05\/source-4280758_1280-375x250.jpg\" class=\"attachment-icatch375 size-icatch375 wp-post-image\" alt=\"\" \/><\/a><\/div>\r\n\t\t\t<\/div>\n<p>Excel\u306eVBA\u3092\u5229\u7528\u3057\u3066\u3001Access\u306e\u30a2\u30af\u30b7\u30e7\u30f3\u30af\u30a8\u30ea\u3092\u5b9f\u884c\u3057\u3001\u30bb\u30eb\u306b\u30b3\u30d4\u30fc\u3059\u308b\u57fa\u672c\u7684\u306a\u30b3\u30fc\u30c9\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n<pre class=\"show-lang:2 lang:vb decode:true\">    Dim cnn As ADODB.Connection\r\n    Dim rst As ADODB.Recordset\r\n    \r\n    ' \u30b3\u30cd\u30af\u30b7\u30e7\u30f3\u3092\u30bb\u30c3\u30c8\u3057\u3001Access\u3092\u958b\u304f\r\n    Set cnn = New ADODB.Connection\r\n    cnn.Provider = \"Microsoft.Ace.OLEDB.12.0;\"\r\n    cnn.Open ThisWorkbook.Path &amp; \"\\ado1.accdb\"\r\n\r\n    '\u30ec\u30b3\u30fc\u30c9\u30bb\u30c3\u30c8\u3092\u30bb\u30c3\u30c8\r\n    Set rst = New ADODB.Recordset\r\n    \r\n    'Access\u306e\u30a2\u30af\u30b7\u30e7\u30f3\u30af\u30a8\u30ea\u3092\u958b\u304f\r\n    rst.Open \"Q_data\", cnn\r\n    \r\n    If rst.EOF Then\r\n        MsgBox \"\u30c7\u30fc\u30bf\u304c\u3042\u308a\u307e\u305b\u3093\u3002\", vbInformation\r\n    Else\r\n        '\u30ec\u30b3\u30fc\u30c9\u3092A1\u30bb\u30eb\u3078\u8cbc\u308a\u4ed8\u3051\u308b\r\n        Range(\"A1\").CopyFromRecordset rst\r\n    End If\r\n    \r\n    ' \u9589\u3058\u308b\r\n    rst.Close\r\n    cnn.Close\r\n    \r\n    ' \u89e3\u653e\u3059\u308b\r\n    Set rst = Nothing\r\n    Set cnn = Nothing<\/pre>\n<p>\u3053\u3053\u3067\u5927\u304d\u306a\u843d\u3068\u3057\u7a74\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<h2>Access\u306e\u30a2\u30af\u30b7\u30e7\u30f3\u30af\u30a8\u30ea\u5b9f\u884c\u306f\u3001\u30a2\u30b9\u30bf\u30ea\u30b9\u30af(*)\u306e\u30ef\u30a4\u30eb\u30c9\u30ab\u30fc\u30c9\u6587\u5b57\u3092\u4f7f\u3046<\/h2>\n<p>Access\u3067\u30a2\u30af\u30b7\u30e7\u30f3\u30af\u30a8\u30ea\u3092\u5b9f\u884c\u3059\u308b\u5834\u5408\u3001LIKE\u306e\u30ef\u30a4\u30eb\u30c9\u30ab\u30fc\u30c9\u306f\u30a2\u30b9\u30bf\u30ea\u30b9\u30af(*)\u3067\u3059\u3002\u3053\u3053\u306f\u3001\u62bd\u51fa\u6761\u4ef6\u3067\u300cLIKE &#8220;*\u672d\u5e4c*&#8221;\u300d\u3068\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/sunafukin.jp\/wp-content\/uploads\/2021\/06\/ado1.png\" rel=\"shadowbox[sbpost-918];player=img;\"><img decoding=\"async\" class=\"aligncenter size-medium wp-image-921\" src=\"https:\/\/sunafukin.jp\/wp-content\/themes\/the-thor\/img\/dummy.gif\" data-layzr=\"https:\/\/sunafukin.jp\/wp-content\/uploads\/2021\/06\/ado1-300x164.png\" alt=\"Access\u3067\u30a2\u30af\u30b7\u30e7\u30f3\u30af\u30a8\u30ea\u3092\u5b9f\u884c\u3059\u308b\u5834\u5408LIKE\u306f\u30a2\u30b9\u30bf\u30ea\u30b9\u30af\u3067\u8a2d\u5b9a\u3059\u308b\" width=\"300\" height=\"164\" \/><\/a><\/p>\n<p>\u3057\u304b\u3057\u3001\u30a2\u30b9\u30bf\u30ea\u30b9\u30af\u306e\u307e\u307eVBA\u304b\u3089\u30a2\u30af\u30b7\u30e7\u30f3\u30af\u30a8\u30ea\u3092\u5b9f\u884c\u3059\u308b\u30680\u4ef6\u306b\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/sunafukin.jp\/wp-content\/uploads\/2021\/06\/ado1-2.png\" rel=\"shadowbox[sbpost-918];player=img;\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-922\" src=\"https:\/\/sunafukin.jp\/wp-content\/themes\/the-thor\/img\/dummy.gif\" data-layzr=\"https:\/\/sunafukin.jp\/wp-content\/uploads\/2021\/06\/ado1-2.png\" alt=\"\u30c7\u30fc\u30bf\u304c0\u4ef6\" width=\"230\" height=\"208\" \/><\/a><\/p>\n<h2>Excel\u304b\u3089ADO\u5229\u7528\u3057\u3066\u30a2\u30af\u30b7\u30e7\u30f3\u30af\u30a8\u30ea\u5b9f\u884c\u306f\u3001\u30d1\u30fc\u30bb\u30f3\u30c8(%)\u306e\u30ef\u30a4\u30eb\u30c9\u30ab\u30fc\u30c9\u6587\u5b57\u3092\u4f7f\u3046<\/h2>\n<p>Excel\u304b\u3089ADO(Microsoft ActiveX Data Objects)\u3092\u5229\u7528\u3057\u3066VBA\u3092\u5b9f\u884c\u3059\u308b\u5834\u5408\u3001Like\u306e\u30ef\u30a4\u30eb\u30c9\u30ab\u30fc\u30c9\u306f\u30d1\u30fc\u30bb\u30f3\u30c8(%)\u3067\u3059\u3002SQL\u3068\u540c\u3058\u3067\u3059\u306d\u3002<\/p>\n<p>\u3053\u3053\u306f\u3067\u3001\u300cLIKE &#8220;%\u672d\u5e4c%&#8221;\u300d\u3068\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/sunafukin.jp\/wp-content\/uploads\/2021\/06\/ado1-3.png\" rel=\"shadowbox[sbpost-918];player=img;\"><img decoding=\"async\" class=\"aligncenter size-medium wp-image-924\" src=\"https:\/\/sunafukin.jp\/wp-content\/themes\/the-thor\/img\/dummy.gif\" data-layzr=\"https:\/\/sunafukin.jp\/wp-content\/uploads\/2021\/06\/ado1-3-300x164.png\" alt=\"VBA\u3067\u30a2\u30af\u30b7\u30e7\u30f3\u30af\u30a8\u30ea\u3092\u5b9f\u884c\u3059\u308b\u5834\u5408LIKE\u306f\u30d1\u30fc\u30bb\u30f3\u30c8\u3092\u8a2d\u5b9a\u3059\u308b\" width=\"300\" height=\"164\" \/><\/a><\/p>\n<h2>\u30ef\u30a4\u30eb\u30c9\u30ab\u30fc\u30c9\u6587\u5b57\u306e\u307e\u3068\u3081<\/h2>\n<p>\u307e\u3068\u3081\u308b\u3068\u3001Access\u306e\u30a2\u30af\u30b7\u30e7\u30f3\u30af\u30a8\u30ea\u306e\u62bd\u51fa\u6761\u4ef6\u3067\u672d\u5e4c\u3068\u3044\u3046\u6587\u5b57\u3092\u62bd\u51fa\u3059\u308b\u5834\u5408\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<table style=\"border-collapse: collapse; width: 100%;\" border=\"1\">\n<tbody>\n<tr>\n<td>\u7528\u9014<\/td>\n<td>Access\u3067\u30a2\u30af\u30b7\u30e7\u30f3\u30af\u30a8\u30ea\u5b9f\u884c<\/td>\n<td>VBA\u3067ADO\u3092\u5229\u7528\u3057\u3066\u30a2\u30af\u30b7\u30e7\u30f3\u30af\u30a8\u30ea\u5b9f\u884c<\/td>\n<\/tr>\n<tr>\n<td>\u8aac\u660e<\/td>\n<td>\u30ef\u30a4\u30eb\u30c9\u30ab\u30fc\u30c9\u306f\u30a2\u30b9\u30bf\u30ea\u30b9\u30af(*)<\/td>\n<td>\u30ef\u30a4\u30eb\u30c9\u30ab\u30fc\u30c9\u306f\u30d1\u30fc\u30bb\u30f3\u30c8(%)<\/td>\n<\/tr>\n<tr>\n<td>\u5229\u7528\u4f8b<\/td>\n<td>LIKE &#8220;*\u672d\u5e4c*&#8221;<\/td>\n<td>LIKE &#8220;%\u672d\u5e4c%&#8221;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>VBA\u3067ADO\u3092\u5229\u7528\u3057\u3066\u30c7\u30fc\u30bf\u3092\u62bd\u51fa\u3059\u308b\u969b\u3001\u30a8\u30e9\u30fc\u304c\u8d77\u304d\u3066\u3044\u306a\u3044\u304c\u3001\u30c7\u30fc\u30bf\u304c0\u4ef6\u306b\u306a\u3063\u3066\u3044\u305f\u3089\u3001\u30ef\u30a4\u30eb\u30c9\u30ab\u30fc\u30c9\u3082\u7591\u3063\u305f\u307b\u3046\u304c\u826f\u3044\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002<\/p>\n<p>VBA\u3067SQL\u3092\u6271\u3046\u3068\u304d\u306f\u3001\u6c17\u3092\u3064\u3051\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Excel VBA\u3067Access\u306e\u30a2\u30af\u30b7\u30e7\u30f3\u30af\u30a8\u30ea\u3092\u5b9f\u884c\u3057\u3001\u30bb\u30eb\u306b\u30b3\u30d4\u30fc\u3059\u308b \u81ea\u52d5\u5316\u3092\u884c\u3046\u306b\u3042\u305f\u308a\u3001Access\u306e\u30a2\u30af\u30b7\u30e7\u30f3\u30af\u30a8\u30ea\u3092Excel VBA\u3092\u5229\u7528\u3057\u3066\u5b9f\u884c\u3059\u308b\u6a5f\u4f1a\u304c\u3042\u3063\u305f\u306e\u3067\u8abf\u67fb\u3057\u307e\u3057\u305f\u3002 VBA\u3092\u5b9f\u884c\u3059\u308b\u524d\u306b\u3001\u300cMicrosoft ActiveX Data Objects 6.1 Libraly\u300d\u307e\u305f\u306f\u300cMicrosoft ActiveX Data Objects 2.X Libral [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":599,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[230],"tags":[260,257,110,113,258,259],"class_list":["post-918","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-vba","tag-access","tag-ado","tag-excel","tag-vba","tag-258","tag-259"],"_links":{"self":[{"href":"https:\/\/sunafukin.jp\/index.php?rest_route=\/wp\/v2\/posts\/918"}],"collection":[{"href":"https:\/\/sunafukin.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sunafukin.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sunafukin.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sunafukin.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=918"}],"version-history":[{"count":17,"href":"https:\/\/sunafukin.jp\/index.php?rest_route=\/wp\/v2\/posts\/918\/revisions"}],"predecessor-version":[{"id":1076,"href":"https:\/\/sunafukin.jp\/index.php?rest_route=\/wp\/v2\/posts\/918\/revisions\/1076"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sunafukin.jp\/index.php?rest_route=\/wp\/v2\/media\/599"}],"wp:attachment":[{"href":"https:\/\/sunafukin.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=918"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sunafukin.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=918"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sunafukin.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=918"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}