{"id":4738,"date":"2016-01-06T08:56:07","date_gmt":"2016-01-05T23:56:07","guid":{"rendered":"http:\/\/excelwork.info\/excel\/?p=4738"},"modified":"2016-01-06T08:56:07","modified_gmt":"2016-01-05T23:56:07","slug":"textwrite","status":"publish","type":"post","link":"https:\/\/excelwork.info\/excel\/textwrite\/","title":{"rendered":"\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\uff1a\u30c7\u30fc\u30bf\u3092\u66f8\u304d\u8fbc\u3080\uff08Write # \u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8\uff09"},"content":{"rendered":"<h2>Write # \u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8<\/h2>\n<div class=\"m30-l\">\n<p><a href=\"https:\/\/excelwork.info\/excel\/textopenclose\/\">Open \u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8<\/a> \u3092<strong>\u30b7\u30fc\u30b1\u30f3\u30b7\u30e3\u30eb\u51fa\u529b\u30e2\u30fc\u30c9\uff08Output\uff09<\/strong>\u307e\u305f\u306f<strong>\u8ffd\u52a0\u30e2\u30fc\u30c9\uff08Append\uff09<\/strong>\u3067\u958b\u3044\u305f\u30d5\u30a1\u30a4\u30eb\u306b\u30c7\u30fc\u30bf\u3092\u66f8\u304d\u8fbc\u307f\u307e\u3059\u3002\u66f8\u304d\u8fbc\u307e\u308c\u308b\u30c7\u30fc\u30bf\u9593\u306b\u306f\u3001\u30ab\u30f3\u30de\uff08,\uff09\u304c\u633f\u5165\u3055\u308c\u307e\u3059\u3002<\/p>\n<br \/>\n<div class=\"kkbox\"><strong>\u3010\u69cb\u6587\u3011<\/strong><\/p>\n<p>    <strong>Write<\/strong> <strong>#<\/strong><em>filenumber<\/em>, [ <em>outputlist<\/em>, &#8230; ]<\/p><\/div>\n<br \/>\n<h4>\u5f15\u6570\u30fb\u623b\u308a\u5024<\/h3>\n<div class=\"m30-l\">\n<ul style=\"margin-top:0;margin-bottom:0;padding-top:0;padding-bottom:0;\">\n<li>filenumber&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;<strong>Open \u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8<\/strong> \u3067\u3001\u5272\u308a\u5f53\u3066\u3089\u308c\u305f\u30d5\u30a1\u30a4\u30eb\u756a\u53f7\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/li>\n<li>outputlist&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u30d5\u30a1\u30a4\u30eb\u306b\u66f8\u304d\u8fbc\u3080\u5024\uff08\u6570\u5f0f\u3084\u6587\u5b57\u5217\u5f0f\uff09\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002\u8907\u6570\u6307\u5b9a\u3059\u308b\u5834\u5408\u306f\u3001\u30ab\u30f3\u30de\uff08,\uff09\u3067\u533a\u5207\u3063\u3066\u6307\u5b9a\u3057\u307e\u3059\u3002\u5f15\u6570 <em>outputlist<\/em> \u3092\u7701\u7565\u3059\u308b\u3068\u30d5\u30a1\u30a4\u30eb\u306b\u306f\u7a7a\u767d\u884c\u304c\u66f8\u304d\u8fbc\u307e\u308c\u307e\u3059\u3002\u3053\u306e\u3068\u304d\u3001\u76f4\u524d\u306e\u30ab\u30f3\u30de\uff08,\uff09\u306f\u7701\u7565\u3067\u304d\u307e\u305b\u3093\u3002<\/li>\n<ol>\n<li>\u6587\u5b57\u5217\u30c7\u30fc\u30bf\u306e\u5834\u5408\u3001\u30c0\u30d6\u30eb\u30af\u30a9\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\uff08&#8221;\uff09\u3067\u56f2\u307e\u308c\u3066\u66f8\u304d\u8fbc\u307e\u308c\u307e\u3059\u3002<\/li>\n<li>\u30d6\u30fc\u30eb\u578b\uff08Boolean\uff09\u306e\u30c7\u30fc\u30bf\u306e\u5834\u5408\u3001<strong>#TRUE#<\/strong> \u307e\u305f\u306f <strong>#FALSE#<\/strong> \u304c\u66f8\u304d\u8fbc\u307e\u308c\u307e\u3059\u3002<\/li>\n<li>\u65e5\u4ed8\u578b\uff08Date\uff09\u306e\u30c7\u30fc\u30bf\u306e\u5834\u5408\u3001<strong>\u6c4e\u7528\u65e5\u4ed8\u5f62\u5f0f\uff08#yyyy-mm-dd hh:mm:ss#\u3001#yyyy-mm-dd#\u3001#hh:mm:ss#\uff09<\/strong>\u3092\u4f7f\u7528\u3057\u3066\u66f8\u304d\u8fbc\u307e\u308c\u307e\u3059\u3002<\/li>\n<li>Null \u30c7\u30fc\u30bf\u306e\u5834\u5408\u3001<strong>#NULL#<\/strong> \u304c\u66f8\u304d\u8fbc\u307e\u308c\u307e\u3059\u3002<\/li>\n<li>Error \u30c7\u30fc\u30bf\u306e\u5834\u5408\u3001<strong>#ERROR <em>errorcode<\/em>#<\/strong> \u304c\u66f8\u304d\u8fbc\u307e\u308c\u307e\u3059\u3002<\/li>\n<li>Empty \u306e\u5834\u5408\u306f\u3001\u4f55\u3082\u66f8\u304d\u8fbc\u307e\u308c\u307e\u305b\u3093\u3002<\/li>\n<li>\u5f15\u6570 <em>outputlist<\/em> \u306b\u3001\u8907\u6570\u6307\u5b9a\u3057\u305f\u5834\u5408\u3001\u30c7\u30fc\u30bf\u9593\u306b\u306f\u30ab\u30f3\u30de\uff08,\uff09\u304c\u633f\u5165\u3055\u308c\u307e\u3059\u3002<\/li>\n<\/ol>\n<\/ul><\/div>\n<br \/>\n<p class=\"caution4\"><strong>Write # \u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8<\/strong>\u3067\u306f\u3001\u5f15\u6570 <em>outputlist<\/em> \u306e\u6700\u5f8c\u306e\u6587\u5b57\u304c\u30d5\u30a1\u30a4\u30eb\u306b\u66f8\u304d\u8fbc\u307e\u308c\u305f\u5f8c\u306b\u3001\u6539\u884c\u6587\u5b57\u306e\u30ad\u30e3\u30ea\u30c3\u30b8\u30ea\u30bf\u30fc\u30f3\u3068\u30e9\u30a4\u30f3\u30d5\u30a3\u30fc\u30c9\uff08 Chr(13) + Chr(10) \uff09\u304c\u633f\u5165\u3055\u308c\u307e\u3059\u3002<\/p>\n<p class=\"caution4\"><strong>Write # \u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8<\/strong>\u3067\u66f8\u304d\u8fbc\u307e\u308c\u308b\u30c7\u30fc\u30bf\u306f\u3001\u901a\u5e38\u3001<strong>Input # \u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8<\/strong>\u3067\u30d5\u30a1\u30a4\u30eb\u304b\u3089\u8aad\u307f\u53d6\u3089\u308c\u307e\u3059\u3002<\/p>\n<\/div>\n<br \/><br \/>\n<h2>Write # \u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8 \u4f7f\u7528\u4f8b<\/h2>\n<div class=\"m30-l\">\n<h3 id=\"vba_sample\">\u30b5\u30f3\u30d7\u30ebVBA\u30bd\u30fc\u30b9 1<\/h3>\n<pre class=\"lang:vb mark:0 decode:true \" title=\"Output \u30e2\u30fc\u30c9 \u4f7f\u7528\u4f8b\" data-url=\"http:\/\/example.co.jp\" >\r\n\u3000\r\nSub Sample_Write_Output()\r\n\r\n    '\u30ab\u30f3\u30de\u533a\u5207\u308a\u306e\u30c7\u30fc\u30bf\u3092\u66f8\u304d\u8fbc\u3080\uff08Output \u30e2\u30fc\u30c9\u30fbWrite # \u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8\uff09\r\n    '\u300cSheet1\u300d\u306e\u8868\u3092\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u306b\u66f8\u304d\u8fbc\u3080\r\n    '\u30d5\u30a1\u30a4\u30eb\u304c\u5b58\u5728\u3057\u306a\u3044\u5834\u5408\u306f\u65b0\u898f\u4f5c\u6210\u3001\u30d5\u30a1\u30a4\u30eb\u304c\u65e2\u306b\u5b58\u5728\u3059\u308b\u5834\u5408\u306f\u3001\u5185\u5bb9\u3092\u4e0a\u66f8\u304d\r\n    \r\n    Dim w As Worksheet\r\n    Dim myRng As Range\r\n    \r\n    Dim FileName As String\r\n    Dim FNum As Integer\r\n    \r\n    Dim i As Integer\r\n        \r\n    Set w = Worksheets(\"Sheet1\")\r\n    Set myRng = w.Range(\"A1\").CurrentRegion\r\n    \r\n    FileName = \"C:\\Documents\\mydata\\file01.txt\"\r\n    FNum = FreeFile     '\u30d5\u30a1\u30a4\u30eb\u756a\u53f7\u53d6\u5f97\r\n    \r\n    '\u30d5\u30a1\u30a4\u30eb\u3092\u958b\u304f\uff08Output \u30e2\u30fc\u30c9\uff09\r\n    Open FileName For Output As #FNum\r\n    \r\n        For i = 2 To myRng.Rows.Count\r\n            \r\n            '\u30ab\u30f3\u30de\u533a\u5207\u308a\u3067\u30c7\u30fc\u30bf\u3092\u66f8\u304d\u8fbc\u3080\r\n            Write #FNum, myRng(i, 1).Value, myRng(i, 2).Value, myRng(i, 3).Value\r\n        \r\n        Next i\r\n    \r\n    '\u30d5\u30a1\u30a4\u30eb\u3092\u9589\u3058\u308b\r\n    Close #FNum\r\n\r\nEnd Sub\r\n\u3000\r\n  <\/pre>\n<br \/>\n<h3>\u5b9f\u884c\u7d50\u679c<\/h3>\n<p>\u300cSheet1\u300d\u306e\u8868<\/p>\n<p><a href=\"https:\/\/i2.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/12\/textwrite00.jpg?ssl=1\" rel=\"lightbox[4738]\"><img loading=\"lazy\" src=\"https:\/\/i2.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/12\/textwrite00.jpg?resize=552%2C263&#038;ssl=1\" alt=\"Write # \u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8\u300000\" width=\"552\" height=\"263\" class=\"alignnone size-full wp-image-4741\" srcset=\"https:\/\/i2.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/12\/textwrite00.jpg?w=552&amp;ssl=1 552w, https:\/\/i2.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/12\/textwrite00.jpg?resize=400%2C191&amp;ssl=1 400w\" sizes=\"(max-width: 552px) 100vw, 552px\" data-recalc-dims=\"1\" \/><\/a><br \/>\n  <br \/><\/p>\n<p>\u30b5\u30f3\u30d7\u30ebVBA\u30bd\u30fc\u30b9 \u5b9f\u884c\u5f8c\u306b\u4f5c\u6210\u3055\u308c\u305f\u30d5\u30a1\u30a4\u30eb\u306e\u5185\u5bb9<\/p>\n<p><a href=\"https:\/\/i1.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/12\/textwrite01.jpg?ssl=1\" rel=\"lightbox[4738]\"><img loading=\"lazy\" src=\"https:\/\/i1.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/12\/textwrite01.jpg?resize=580%2C308&#038;ssl=1\" alt=\"Write # \u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8 01\" width=\"580\" height=\"308\" class=\"alignnone size-large wp-image-4742\" srcset=\"https:\/\/i1.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/12\/textwrite01.jpg?resize=580%2C308&amp;ssl=1 580w, https:\/\/i1.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/12\/textwrite01.jpg?resize=400%2C213&amp;ssl=1 400w, https:\/\/i1.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/12\/textwrite01.jpg?w=621&amp;ssl=1 621w\" sizes=\"(max-width: 580px) 100vw, 580px\" data-recalc-dims=\"1\" \/><\/a><\/p>\n<br \/><br \/>\n<h3 id=\"vba_sample\">\u30b5\u30f3\u30d7\u30ebVBA\u30bd\u30fc\u30b9 2<\/h3>\n<pre class=\"lang:vb mark:0 decode:true \" title=\"Append \u30e2\u30fc\u30c9 \u4f7f\u7528\u4f8b\" data-url=\"http:\/\/example.co.jp\" >\r\n\u3000\r\nSub Sample_Write_Append()\r\n\r\n    '\u30ab\u30f3\u30de\u533a\u5207\u308a\u306e\u30c7\u30fc\u30bf\u3092\u8ffd\u8a18\u3059\u308b\uff08Append \u30e2\u30fc\u30c9\u30fbWrite # \u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8\uff09\r\n    \r\n    Dim myData(2)\r\n    myData(0) = Array(6, \"\u82b1\u7530\u307f\u304d\", #2\/3\/2012#)\r\n    myData(1) = Array(7, \"\u9999\u5ddd\u3055\u304f\u3089\", #2\/5\/2012#)\r\n    myData(2) = Array(8, \"\u5c71\u5ddd\u5f18\u7f8e\", #3\/5\/2012#)\r\n\r\n    Dim FileName As String\r\n    Dim FNum As Integer\r\n    Dim i As Integer\r\n        \r\n    FileName = \"C:\\Documents\\mydata\\file01.txt\"\r\n    FNum = FreeFile     '\u30d5\u30a1\u30a4\u30eb\u756a\u53f7\u53d6\u5f97\r\n    \r\n    '\u30d5\u30a1\u30a4\u30eb\u3092\u958b\u304f\uff08Append \u30e2\u30fc\u30c9\uff09\r\n    Open FileName For Append As #FNum\r\n    \r\n        For i = 0 To UBound(myData)\r\n            \r\n            '\u30ab\u30f3\u30de\u533a\u5207\u308a\u3067\u30c7\u30fc\u30bf\u3092\u66f8\u304d\u8fbc\u3080\r\n            Write #FNum, myData(i)(0), myData(i)(1), myData(i)(2)\r\n        \r\n        Next i\r\n    \r\n    '\u30d5\u30a1\u30a4\u30eb\u3092\u9589\u3058\u308b\r\n    Close #FNum\r\n    \r\nEnd Sub\r\n\u3000\r\n  <\/pre>\n<br \/>\n<h3>\u5b9f\u884c\u7d50\u679c<\/h3>\n<p>\u30b5\u30f3\u30d7\u30ebVBA\u30bd\u30fc\u30b9 2 \u5b9f\u884c\u5f8c\u306b\u4f5c\u6210\u3055\u308c\u305f\u30d5\u30a1\u30a4\u30eb\u306e\u5185\u5bb9<\/p>\n<p><a href=\"https:\/\/i1.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/12\/textwrite02.jpg?ssl=1\" rel=\"lightbox[4738]\"><img loading=\"lazy\" src=\"https:\/\/i1.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/12\/textwrite02.jpg?resize=580%2C308&#038;ssl=1\" alt=\"Write # \u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8 02\" width=\"580\" height=\"308\" class=\"alignnone size-large wp-image-4744\" srcset=\"https:\/\/i1.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/12\/textwrite02.jpg?resize=580%2C308&amp;ssl=1 580w, https:\/\/i1.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/12\/textwrite02.jpg?resize=400%2C213&amp;ssl=1 400w, https:\/\/i1.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/12\/textwrite02.jpg?w=621&amp;ssl=1 621w\" sizes=\"(max-width: 580px) 100vw, 580px\" data-recalc-dims=\"1\" \/><\/a><\/p>\n<\/div>\n<br \/><br \/>\n","protected":false},"excerpt":{"rendered":"<p>Write # \u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8 Open \u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8 \u3092\u30b7\u30fc\u30b1\u30f3\u30b7\u30e3\u30eb\u51fa\u529b\u30e2 &#8230; <\/p>\n","protected":false},"author":1,"featured_media":4741,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"amp_status":"","spay_email":"","jetpack_publicize_message":""},"categories":[675],"tags":[693,731,63,739,38,729],"jetpack_featured_media_url":"https:\/\/i2.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/12\/textwrite00.jpg?fit=552%2C263&ssl=1","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p4Ye9i-1eq","_links":{"self":[{"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/posts\/4738"}],"collection":[{"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/comments?post=4738"}],"version-history":[{"count":10,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/posts\/4738\/revisions"}],"predecessor-version":[{"id":4849,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/posts\/4738\/revisions\/4849"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/media\/4741"}],"wp:attachment":[{"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/media?parent=4738"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/categories?post=4738"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/tags?post=4738"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}