{"id":13108,"date":"2026-02-26T22:08:29","date_gmt":"2026-02-26T13:08:29","guid":{"rendered":"https:\/\/pineplanter.moo.jp\/non-it-salaryman\/?p=13108"},"modified":"2026-02-26T22:08:29","modified_gmt":"2026-02-26T13:08:29","slug":"xserver-db-vba","status":"publish","type":"post","link":"http:\/\/pineplanter.moo.jp\/non-it-salaryman\/2026\/02\/26\/xserver-db-vba\/","title":{"rendered":"\u3010ExcelVBA\u3011XserverVPS\u4e0a\u306eMySQL\u3092Excel\u304b\u3089\u76f4\u63a5\u64cd\u4f5c\u3059\u308b"},"content":{"rendered":"<p>Excel VBA\u3092\u7528\u3044\u3066Xserver VPS\u4e0a\u306b\u69cb\u7bc9\u3055\u308c\u305fMySQL\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3078\u76f4\u63a5\u30a2\u30af\u30bb\u30b9\u3057\u3001\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u30fb\u64cd\u4f5c\u3059\u308b\u65b9\u6cd5\u3067\u3059\u3002Python\u7b49\u306e\u5916\u90e8\u8a00\u8a9e\u3092\u4ecb\u3055\u305a\u3001Excel\u6a19\u6e96\u306e\u6a5f\u80fd\u3067\u3042\u308bADO\uff08ActiveX Data Objects\uff09\u3068MySQL\u63d0\u4f9b\u306eODBC\u30c9\u30e9\u30a4\u30d0\u3092\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u3067\u3001\u65e2\u5b58\u306e\u5e33\u7968\u51fa\u529b\u3092\u5287\u7684\u306b\u9ad8\u901f\u5316\u3067\u304d\u308b\u3002\u30c9\u30e9\u30a4\u30d0\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u304b\u3089\u3001\u5177\u4f53\u7684\u306a\u63a5\u7d9a\u30b3\u30fc\u30c9\u306e\u5b9f\u88c5\u307e\u3067\u3092\u66f8\u304d\u7559\u3081\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<h2>Connector\/ODBC \u306e\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u30fb\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h2>\n<p>\u307e\u305a\u306fWindows\u3068MySQL\u3092\u6a4b\u6e21\u3057\u3059\u308b\u300cConnector\/ODBC\u300d\u3092\u5165\u624b\u3057\u307e\u3059\u3002<\/p>\n<ol>\n<li><a href=\"https:\/\/dev.mysql.com\/downloads\/connector\/odbc\/\" target=\"_blank\" rel=\"noopener\">MySQL\u516c\u5f0f\u30b5\u30a4\u30c8<\/a>\u3078\u30a2\u30af\u30bb\u30b9\u3057\u307e\u3059\u3002<\/li>\n<li>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u3044\u308b Excel\u306e\u30d3\u30c3\u30c8\u6570\uff0832bit\/64bit\uff09 \u306b\u5408\u308f\u305b\u305f\u30a4\u30f3\u30b9\u30c8\u30fc\u30e9\u30fc\uff08MSI Installer\uff09\u3092\u9078\u629e\u3057\u307e\u3057\u3087\u3046\u3002<br \/>\n\u203bWindows\u304c64bit\u3067\u3082\u3001Excel\u304c32bit\u306a\u308932bit\u7248\u30c9\u30e9\u30a4\u30d0\u304c\u5fc5\u8981\u3067\u3059\u3002<\/li>\n<li>\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u30dc\u30bf\u30f3\u62bc\u4e0b\u5f8c\u3001\u30b5\u30a4\u30f3\u30a2\u30c3\u30d7\u3092\u4fc3\u3055\u308c\u307e\u3059\u304c\u3001\u4e0b\u90e8\u306e &#8220;<strong>No thanks, just start my download.<\/strong>&#8221; \u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3053\u3068\u3067\u767b\u9332\u306a\u3057\u3067\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u53ef\u80fd\u3067\u3059\u3002<\/li>\n<li>\u5165\u624b\u3057\u305f .msi \u30d5\u30a1\u30a4\u30eb\u3092\u5b9f\u884c\u3057\u3001\u6a19\u6e96\u8a2d\u5b9a\u306e\u307e\u307e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3092\u5b8c\u4e86\u3055\u305b\u307e\u3059\u3002<\/li>\n<\/ol>\n<p><a href=\"http:\/\/pineplanter.moo.jp\/non-it-salaryman\/wp-content\/uploads\/2026\/02\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2026-02-26-215730.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-13110\" src=\"http:\/\/pineplanter.moo.jp\/non-it-salaryman\/wp-content\/uploads\/2026\/02\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2026-02-26-215730-700x514.png\" alt=\"\" width=\"700\" height=\"514\" srcset=\"http:\/\/pineplanter.moo.jp\/non-it-salaryman\/wp-content\/uploads\/2026\/02\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2026-02-26-215730-700x514.png 700w, http:\/\/pineplanter.moo.jp\/non-it-salaryman\/wp-content\/uploads\/2026\/02\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2026-02-26-215730-900x661.png 900w, http:\/\/pineplanter.moo.jp\/non-it-salaryman\/wp-content\/uploads\/2026\/02\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2026-02-26-215730.png 1213w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<h2>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u6e08\u307f\u30c9\u30e9\u30a4\u30d0\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u78ba\u8a8d<\/h2>\n<p>VBA\u306b\u8a18\u8ff0\u3059\u308b\u300c\u6b63\u78ba\u306a\u30c9\u30e9\u30a4\u30d0\u540d\u300d\u3092\u7279\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<ol>\n<li>Windows\u306e\u691c\u7d22\u30d0\u30fc\u306b \u300cODBC\u300d \u3068\u5165\u529b\u3057\u3001\u300cODBC \u30c7\u30fc\u30bf\u30bd\u30fc\u30b9 (64\u30d3\u30c3\u30c8)\u300d\uff08\u307e\u305f\u306f32\u30d3\u30c3\u30c8\uff09\u3092\u8d77\u52d5\u3057\u307e\u3059\u3002<\/li>\n<li>\u300c\u30c9\u30e9\u30a4\u30d0\u30fc\u300d \u30bf\u30d6\u3092\u30af\u30ea\u30c3\u30af\u3057\u3001\u4e00\u89a7\u306b\u3042\u308b\u540d\u524d\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/li>\n<li>MySQL ODBC 9.6 Unicode Driver \u306a\u3069\u3001\u8868\u793a\u3055\u308c\u3066\u3044\u308b\u6587\u5b57\u5217\u3092\u30e1\u30e2\u3057\u307e\u3059\u3002<br \/>\n\u203b\u3053\u306e\u6587\u5b57\u5217\u304c1\u6587\u5b57\u3067\u3082\u9055\u3046\u3068\u3001VBA\u5b9f\u884c\u6642\u306b\u300c\u30c9\u30e9\u30a4\u30d0\u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093\u300d\u3068\u3044\u3046\u30a8\u30e9\u30fc\u306b\u306a\u308a\u307e\u3059\u3002<\/li>\n<\/ol>\n<p><a href=\"http:\/\/pineplanter.moo.jp\/non-it-salaryman\/wp-content\/uploads\/2026\/02\/odbc.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-13113\" src=\"http:\/\/pineplanter.moo.jp\/non-it-salaryman\/wp-content\/uploads\/2026\/02\/odbc-700x484.png\" alt=\"\" width=\"700\" height=\"484\" srcset=\"http:\/\/pineplanter.moo.jp\/non-it-salaryman\/wp-content\/uploads\/2026\/02\/odbc-700x484.png 700w, http:\/\/pineplanter.moo.jp\/non-it-salaryman\/wp-content\/uploads\/2026\/02\/odbc-900x623.png 900w, http:\/\/pineplanter.moo.jp\/non-it-salaryman\/wp-content\/uploads\/2026\/02\/odbc.png 1038w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h2>VBA\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306e\u5b9f\u88c5<\/h2>\n<p>\u6a19\u6e96\u30e2\u30b8\u30e5\u30fc\u30eb\u306b\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3092\u8a18\u8ff0\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\nSub ConnectToMySQL()\r\n    &#039; ADO\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u5ba3\u8a00\uff08\u5b9f\u884c\u6642\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\uff09\r\n    Dim conn As Object\r\n    Dim rs As Object\r\n    Dim connectionString As String\r\n    \r\n    &#039; \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u751f\u6210\r\n    Set conn = CreateObject(&quot;ADODB.Connection&quot;)\r\n    Set rs = CreateObject(&quot;ADODB.Recordset&quot;)\r\n    \r\n    &#039; --- \u63a5\u7d9a\u6587\u5b57\u5217\u306e\u8a2d\u5b9a ---\r\n    &#039; DRIVER: ODBC\u30c7\u30fc\u30bf\u30bd\u30fc\u30b9\u3067\u78ba\u8a8d\u3057\u305f\u6b63\u78ba\u306a\u540d\u79f0\u3092\u6307\u5b9a\r\n    &#039; SERVER: \u30b5\u30fc\u30d0\u30fc\u306e\u30c9\u30e1\u30a4\u30f3\u540d\u307e\u305f\u306fIP\u30a2\u30c9\u30ec\u30b9\r\n    connectionString = &quot;DRIVER={MySQL ODBC 9.2 Unicode Driver};&quot; &amp; _\r\n                       &quot;SERVER=satoshi71.com;&quot; &amp; _\r\n                       &quot;DATABASE=database_name;&quot; &amp; _\r\n                       &quot;USER=admin;&quot; &amp; _\r\n                       &quot;PASSWORD=your_password;&quot; &amp; _\r\n                       &quot;PORT=3306;&quot; &amp; _\r\n                       &quot;OPTION=3;&quot;\r\n\r\n    On Error GoTo ErrorHandler\r\n    \r\n    &#039; \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u63a5\u7d9a\u958b\u59cb\r\n    conn.Open connectionString\r\n    \r\n    &#039; SQL\u30af\u30a8\u30ea\u306e\u5b9f\u884c\uff08users\u30c6\u30fc\u30d6\u30eb\u304b\u3089\u5168\u4ef6\u53d6\u5f97\uff09\r\n    rs.Open &quot;SELECT * FROM users&quot;, conn\r\n    \r\n    &#039; \u30bb\u30ebA1\u3092\u8d77\u70b9\u306b\u3001\u53d6\u5f97\u3057\u305f\u30ec\u30b3\u30fc\u30c9\u30bb\u30c3\u30c8\u3092\u4e00\u62ec\u5c55\u958b\r\n    If Not rs.EOF Then\r\n        Sheet1.Range(&quot;A1&quot;).CopyFromRecordset rs\r\n    End If\r\n    \r\n    MsgBox &quot;\u30c7\u30fc\u30bf\u306e\u8aad\u307f\u8fbc\u307f\u306b\u6210\u529f\u3057\u307e\u3057\u305f\u3002&quot;, vbInformation\r\n    \r\nCleanUp:\r\n    &#039; \u5f8c\u51e6\u7406\uff1a\u63a5\u7d9a\u3092\u9589\u3058\u3066\u30e1\u30e2\u30ea\u3092\u89e3\u653e\r\n    If Not rs Is Nothing Then If rs.State = 1 Then rs.Close\r\n    If Not conn Is Nothing Then If conn.State = 1 Then conn.Close\r\n    Set rs = Nothing\r\n    Set conn = Nothing\r\n    Exit Sub\r\n\r\nErrorHandler:\r\n    &#039; \u30a8\u30e9\u30fc\u767a\u751f\u6642\u306e\u901a\u77e5\uff08\u63a5\u7d9a\u6587\u5b57\u5217\u306e\u30df\u30b9\u3084\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30a8\u30e9\u30fc\u306a\u3069\uff09\r\n    MsgBox &quot;\u63a5\u7d9a\u5931\u6557: &quot; &amp; Err.Description, vbCritical\r\n    Resume CleanUp\r\nEnd Sub\r\n \r\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Excel VBA\u3092\u7528\u3044\u3066Xserver VPS\u4e0a\u306b\u69cb\u7bc9\u3055\u308c\u305fMySQL\u30c7\u30fc\u30bf\u30d9 &#8230; <\/p>\n","protected":false},"author":1,"featured_media":13115,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,6,63],"tags":[],"class_list":["post-13108","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-excel","category-vba","category-xserver-vps"],"aioseo_notices":[],"_links":{"self":[{"href":"http:\/\/pineplanter.moo.jp\/non-it-salaryman\/wp-json\/wp\/v2\/posts\/13108","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/pineplanter.moo.jp\/non-it-salaryman\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/pineplanter.moo.jp\/non-it-salaryman\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/pineplanter.moo.jp\/non-it-salaryman\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/pineplanter.moo.jp\/non-it-salaryman\/wp-json\/wp\/v2\/comments?post=13108"}],"version-history":[{"count":2,"href":"http:\/\/pineplanter.moo.jp\/non-it-salaryman\/wp-json\/wp\/v2\/posts\/13108\/revisions"}],"predecessor-version":[{"id":13114,"href":"http:\/\/pineplanter.moo.jp\/non-it-salaryman\/wp-json\/wp\/v2\/posts\/13108\/revisions\/13114"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/pineplanter.moo.jp\/non-it-salaryman\/wp-json\/wp\/v2\/media\/13115"}],"wp:attachment":[{"href":"http:\/\/pineplanter.moo.jp\/non-it-salaryman\/wp-json\/wp\/v2\/media?parent=13108"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/pineplanter.moo.jp\/non-it-salaryman\/wp-json\/wp\/v2\/categories?post=13108"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/pineplanter.moo.jp\/non-it-salaryman\/wp-json\/wp\/v2\/tags?post=13108"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}