{"id":9046,"date":"2014-04-16T08:32:08","date_gmt":"2014-04-15T23:32:08","guid":{"rendered":"http:\/\/35.247.82.29\/wpbl\/?p=9046"},"modified":"2021-08-10T05:35:59","modified_gmt":"2021-08-09T20:35:59","slug":"9046","status":"publish","type":"post","link":"https:\/\/mole-kingdom.com\/wpbl\/2014\/04\/16\/9046.html","title":{"rendered":"\u30d5\u30c3\u30bf\u30fc\u306e\u66f8\u304d\u63db\u3048(\u30fb\u2200\u30fb)"},"content":{"rendered":"<p>\u305a\u3063\u3068\u524d\u306b\u4ed5\u4e8b\u3067xls\u3084doc\u306efooter\u306e\u5185\u5bb9\u3092\u5909\u3048\u308b\u3053\u3068\u304c\u3042\u3063\u305f\u6642\u306b\u66f8\u3044\u305fVBA\u30b3\u30fc\u30c9\u3002<br \/>\n\u4ed5\u4e8b\u3068\u3057\u3066\u3067\u306f\u306a\u304f\u8a66\u3057\u306b\u5bb6\u3067\u66f8\u3044\u305f\u3082\u306e\u306a\u306e\u3067\u516c\u958b\u3057\u3066\u3082\u554f\u984c\u306a\u3044\u2026\u306f\u305a(\u30fb\u2200\u30fb)<\/p>\n<p>\u307e\u3042\u5185\u5bb9\u7684\u306b\u53e4\u3044\u306e\u3067\u4eca\u66f4\u6709\u52b9\u6d3b\u7528\u51fa\u6765\u308b\u5185\u5bb9\u3067\u306f\u306a\u3044\u3051\u308c\u3069\u3082\u3001<br \/>\n\u3044\u3064\u304b\u307e\u305f\u4f55\u304b\u306e\u5f79\u306b\u7acb\u3064\u304b\u3082\u3057\u308c\u306a\u3044\u306e\u3067\u30a8\u30f3\u30c8\u30ea\u3068\u3057\u3066\u4fdd\u5b58\u3057\u3066\u304a\u3053\u3046\u3002<\/p>\n<p>\u591a\u5206\u3001\u3053\u3061\u3089\u306e\u30a8\u30f3\u30c8\u30ea\u3092\u53c2\u8003\u306b\u3057\u3066\u518d\u5e30\u90e8\u5206\u306f\u66f8\u3044\u305f\u2026\u3088\u3046\u306a\u3002<br \/>\n<a href=\"https:\/\/d.hatena.ne.jp\/language_and_engineering\/20090429\/p1\" target=\"_blank\" rel=\"noopener\">VBA\uff082007\u3082OK\uff09\u3067\uff0c\u30d5\u30a1\u30a4\u30eb\u306e\u518d\u5e30\u691c\u7d22\u3092\u3057\u3088\u3046<\/a><\/p>\n<p>\u305d\u306e\u4ed6\u306e\u90e8\u5206\u306f\u8272\u3005\u306aVBA\u95a2\u9023\u306e\u30b5\u30a4\u30c8\u3084\u30d8\u30eb\u30d7(\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9\uff1f)\u3092<br \/>\n\u53c2\u8003\u306b\u3057\u305f\u3088\u3046\u306a\u6c17\u304c\u3059\u308b\u3051\u3069\u3001\u8a73\u3057\u304f\u306f\u899a\u3048\u3066\u3044\u306a\u3044\u3002<\/p>\n<p>MsgBox\u3068\u304b\u306e\u90e8\u5206\u306f\u304a\u8a66\u3057\u3067\u5165\u308c\u3066\u3044\u308b\u3060\u3051\u306a\u306e\u3067\u672c\u5f53\u306f\u8981\u3089\u306a\u3044\u3002<br \/>\n\u5bfe\u8c61\u3068\u306a\u308b\u30d1\u30b9\u306fxls_test()\u306e\u4e2d\u3067\u76f4\u66f8\u304d\u3057\u3066\u3001\u305d\u3053\u306bxls\u30d5\u30a1\u30a4\u30eb\u7fa4\u3092<br \/>\n\u3076\u3061\u3053\u3093\u3067\u3053\u308c\u3092\u5b9f\u884c\u3059\u308b\u3068\u300cAll Rights Reserved, Copyright \u00a9 \uff5e\u300d<br \/>\n\u307f\u305f\u3044\u306a\u306e\u304c\u53f3\u4e0b\u306efooter\u306b\u8ffd\u52a0\u3055\u308c\u308b\u306f\u305a\u3002<br \/>\nrightfooter\u3092\u4ed6\u306efooter\u3084header\u306b\u4ee3\u3048\u308c\u3070\u4efb\u610f\u306e\u90e8\u5206\u306e\u5024\u3092\u5909\u66f4\u51fa\u6765\u308b\u2026\u306f\u305a\u3002<\/p>\n<p>\u3053\u306e\u307e\u307e\u3067\u52d5\u304f\u304b\u3082\u3057\u308c\u306a\u3044\u3051\u308c\u3069\u3082\u3001\u3053\u306e\u30b3\u30fc\u30c9\u81ea\u4f53\u306f\u5b9f\u5730\u3067<br \/>\n\u8a66\u3057\u305f\u3082\u306e\u3067\u306f\u306a\u3044\u306e\u3067\u4fee\u6b63\u304c\u5fc5\u8981\u304b\u3082(\uff89\u2200`)<\/p>\n<p>doc_test()\u306fWord\u7528\u3002\u78ba\u304b\u3053\u308c\u3067\u52d5\u3044\u305f\u3088\u3046\u306a\u6c17\u304c\u3059\u308b\u2026\u3051\u3069\u81ea\u4fe1\u306f\u306a\u3044\uff57<br \/>\n\u6700\u65b0\u306eOffice\u306eVBA\u306f\u3069\u3046\u306a\u3063\u3066\u308b\u3093\u3060\u308d\u3046\u304b\u3002<\/p>\n<hr>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\nOption Explicit\r\n\r\nFunction FileSearch2007(dir_path, target_extension)\r\n\tDim found_files As Collection\r\n\r\n\tSet found_files = New Collection\r\n\tCall FileSearch2007_Repeat(dir_path, found_files, target_extension)\r\n\tSet FileSearch2007 = found_files\r\nEnd Function\r\n\r\nPrivate Sub FileSearch2007_Repeat(dir_path, found_files, target_extension)\r\n\tDim fso As FileSystemObject\r\n\tDim target_folder As Folder\r\n\tDim sub_folder As Folder\r\n\tDim objFile As File\r\n\r\n\tSet fso = New FileSystemObject\r\n\tSet target_folder = fso.GetFolder(dir_path)\r\n\r\n\tFor Each sub_folder In target_folder.SubFolders\r\n\t\tCall FileSearch2007_Repeat(sub_folder.Path,found_files,target_extension)\r\n\tNext sub_folder\r\n\r\n\tFor Each objFile In target_folder.Files\r\n\t\tWith objFile\r\n\t\t\tIf ((UCase)fso.GetExtensionName(.Path)) = target_extension) Then\r\n\t\t\t\tfound_files.Add Item:=.Path\r\n\t\t\tEnd If\r\n\t\tEnd With\r\n\tNext objFile\r\n\r\n\tSet fso = Nothing\r\nEnd Sub\r\n\r\nSub xls_test()\r\n\tDim dir_path As String\r\n\tDim target_extension As String\r\n\tDim found_files As Collection\r\n\tDim found_num As Integer\r\n\r\n\t\/\/\u3053\u3053\u306b\u5bfe\u8c61\u306e\u30d5\u30a1\u30a4\u30eb\u7fa4\u304c\u3042\u308b\u30d1\u30b9\u3092\u6307\u5b9a\r\n\tdir_path = &quot;&lt;\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30d1\u30b9&gt;&quot; 'ThisWorkbook.Path &amp; &quot;\\test&quot;\r\n\ttarget_extension = UCase(&quot;xls&quot;)\r\n\r\n\tSet found_files = FileSearch2007(dir_path, target_extension)\r\n\r\n\tfound_num = found_files.Count\r\n\tIf found_num = 0 Then\r\n\t\tMsgBox &quot;not found&quot;\r\n\tElse\r\n\t\tMsgBox found_num &amp; &quot; found&quot;\r\n\r\n\t\tDim i As Integer\r\n\t\tDim bookpath As String\r\n\t\tDim TargetBook As Workbook\r\n\t\tDim eachsheet As Worksheet\r\n\r\n\t\tFor i= 1 To found_num\r\n\t\t\tbookpath=found_files(i)\r\n\t\t\tIf Len(bookpath) &gt; 0 Then\r\n\t\t\t\t'MsgBox bookpath\r\n\t\t\t\tSet TargetBook = Workbooks.Open(bookpath)\r\n\r\n\t\t\t\t'Office2010\u306e\u4e92\u63db\u6027\u30c1\u30a7\u30c3\u30af\u3092\u7121\u52b9\u306b\u3059\u308b\u3002\r\n\t\t\t\tDim ret As Variant\r\n\t\t\t\tret = Application.Version\r\n\t\t\t\tIf Val(ret)=14 Then\r\n\t\t\t\t\tActiveWorkbook.CheckCompatibility = False\r\n\t\t\t\tElse\r\n\t\t\t\tEnd If\r\n\r\n\t\t\t\tFor Each eachsheet In TargetBook.Worksheets\r\n\t\t\t\t\tWith eachsheet.PageSetup\r\n\t\t\t\t\t\/\/\u3053\u3053\u3067Footer\u3084Header\u306e\u5024\u3092\u4fee\u6b63\r\n\t\t\t\t\t\tRightFooter = &quot;All Rights Reserved, Copyright &quot; &amp; Chr(169) &amp; &quot;&quot;\r\n\t\t\t\t\tEnd With\r\n\t\t\t\tNext eachsheet\r\n\r\n\t\t\t\tTargetBook.Save\r\n\t\t\t\tTargetBook.Close\r\n\t\t\tEnd If\r\n\t\tNext i\r\n\r\n\t\tMsgBox &quot;xls modified&quot;\r\n\tEnd If\r\nEnd\u3000Sub\r\n\r\nSub doc_test()\r\n\tDim dir_path As String\r\n\tDim target_extension As String\r\n\tDim found_files As Collection\r\n\tDim found_num As Integer\r\n\r\n\tdir_path = &quot;&lt;\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30d1\u30b9&gt;&quot; 'ThisWorkbook.Path &amp; &quot;\\test&quot;\r\n\ttarget_extension = UCase(&quot;doc&quot;)\r\n\r\n\tSet found_files = FileSearch2007(dir_path, target_extension)\r\n\tfound_num = found_files.Count\r\n\tIf found_num = 0 Then\r\n\t\tMsgBox &quot;not found&quot;\r\n\tElse\r\n\t\tMsgBox found_num &amp; &quot; found&quot;\r\n\r\n\t\tDim i As Integer\r\n\t\tDim docpath As String\r\n\t\tDim eachsheet As Worksheet\r\n\t\tDim objWord As Object\r\n\r\n\t\tSet objWord = CreateObject(&quot;Word.Application&quot;)\r\n\t\tFor i = 1 To found_num\r\n\t\t\tdocpath = found_files(i)\r\n\t\t\tIf Len(docpath) &gt; 0 Then\r\n\t\t\t\t'MsgBox docpath\r\n\t\t\t\tWith objWord\r\n\t\t\t\t\t.Documents. Open docpath\r\n\r\n\t\t\t\t\t.ActiveDocument.Section(1).Footers(1).Range.Text=\r\n\t\t\t\t\t&quot;All Rights Reserved, Copyright &quot; &amp; Chr(169) &amp; &quot;&quot;\r\n\r\n\t\t\t\t\t.ActiveDocument.Save\r\n\t\t\t\t\t.ActiveDocument.Close\r\n\t\t\t\tEnd with\r\n\t\t\tEnd if\r\n\t\tNext i\r\n\t\tMsgBox &quot;doc modified&quot;\r\n\tEnd If\r\nEnd Sub\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u305a\u3063\u3068\u524d\u306b\u4ed5\u4e8b\u3067xls\u3084doc\u306efooter\u306e\u5185\u5bb9\u3092\u5909\u3048\u308b\u3053\u3068\u304c\u3042\u3063\u305f\u6642\u306b\u66f8\u3044\u305fVBA\u30b3\u30fc\u30c9\u3002 \u4ed5\u4e8b\u3068\u3057\u3066\u3067\u306f\u306a\u304f\u8a66\u3057\u306b\u5bb6\u3067\u66f8\u3044\u305f\u3082\u306e\u306a\u306e\u3067\u516c\u958b\u3057\u3066\u3082\u554f\u984c\u306a\u3044\u2026\u306f\u305a(\u30fb\u2200\u30fb) \u307e\u3042\u5185\u5bb9\u7684\u306b\u53e4\u3044\u306e\u3067\u4eca\u66f4\u6709\u52b9\u6d3b\u7528\u51fa\u6765\u308b\u5185\u5bb9\u3067...  <a class=\"excerpt-read-more\" href=\"https:\/\/mole-kingdom.com\/wpbl\/2014\/04\/16\/9046.html\" title=\"Read \u30d5\u30c3\u30bf\u30fc\u306e\u66f8\u304d\u63db\u3048(\u30fb\u2200\u30fb)\">\u3082\u3063\u3068\u8aad\u3080 &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[17],"tags":[],"class_list":["post-9046","post","type-post","status-publish","format-standard","hentry","category-programming"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/s2pLuj-9046","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":18650,"url":"https:\/\/mole-kingdom.com\/wpbl\/2018\/03\/12\/18650.html","url_meta":{"origin":9046,"position":0},"title":"\u3046\u306b\u306e\u30c8\u30b2\u306f\u523a\u3055\u308b\u3068\u75db\u3044(\u00b4\uff65\u03c9\uff65\uff40)","author":"moleking","date":"2018\u5e743\u670812\u65e5","format":false,"excerpt":"\u306a\u3093\u304b\u30d3\u30eb\u30c9\u304c\u3067\u304d\u306a\u304f\u306a\u3063\u305f(\u00b4\uff65\u03c9\uff65\uff40) \u307e\u305f\u3069\u3046\u3067\u3082\u826f\u3044\u3053\u3068\u3067\u306f\u307e\u3063\u305f(\u30fd'\u03c9`) \u30ab\u2026","rel":"","context":"Unity","block_context":{"text":"Unity","link":"https:\/\/mole-kingdom.com\/wpbl\/category\/software-2\/unity"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":24361,"url":"https:\/\/mole-kingdom.com\/wpbl\/2021\/05\/24\/24361.html","url_meta":{"origin":9046,"position":1},"title":"\u5de3\u3054\u3082\u308aDX\u30b9\u30c6\u30c3\u30d7\u8b1b\u5ea7\u60c5\u5831\u30ca\u30d3\u3092\u773a\u3081\u308b(\u00b4\uff65\u03c9\uff65\uff40)-5","author":"moleking","date":"2021\u5e745\u670824\u65e5","format":false,"excerpt":"LinkedinLearning Web\u958b\u767a\u8005\u306b\u306a\u308b\u306e\u7d9a\u304d\u3002 React.js \u5165\u9580 2016\u5e749\u6708\u2026","rel":"","context":"\u611f\u60f3","block_context":{"text":"\u611f\u60f3","link":"https:\/\/mole-kingdom.com\/wpbl\/category\/impressions"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":22746,"url":"https:\/\/mole-kingdom.com\/wpbl\/2020\/12\/06\/22746.html","url_meta":{"origin":9046,"position":2},"title":"\u899a\u3048\u66f8\u304d: \u30d0\u30c3\u30c1\u30d5\u30a1\u30a4\u30eb","author":"moleking","date":"2020\u5e7412\u67086\u65e5","format":false,"excerpt":"\u4ee5\u4e0b\u306f\u672c\u5f53\u306f\u304c\u3063\u3064\u308a\u30d0\u30c3\u30c1\u30d5\u30a1\u30a4\u30eb\u306b\u3064\u3044\u3066\u8abf\u3079\u3066\u30a8\u30f3\u30c8\u30ea\u5316\u3057\u3088\u3046\u3068\u601d\u3063\u305f\u304c\u3001\u9014\u4e2d\u3067\u76ee\u7684\u3092\u9054\u6210\u3057\u3066\u3057\u307e\u2026","rel":"","context":"Windows","block_context":{"text":"Windows","link":"https:\/\/mole-kingdom.com\/wpbl\/category\/os\/windows"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/mole-kingdom.com\/wpbl\/wp-content\/uploads\/2020\/12\/bat_cmd_diff01.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":22847,"url":"https:\/\/mole-kingdom.com\/wpbl\/2020\/12\/21\/22847.html","url_meta":{"origin":9046,"position":3},"title":"\u30a8\u30af\u30b9\u30c6\u30f3\u30b7\u30e7\u30f3(\u62e1\u5f35) : kotlin","author":"moleking","date":"2020\u5e7412\u670821\u65e5","format":false,"excerpt":"\u203b\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u306f\u5168\u3066\"Target platform: JVMRunning on kotlin v\u2026","rel":"","context":"kotlin","block_context":{"text":"kotlin","link":"https:\/\/mole-kingdom.com\/wpbl\/category\/programming\/kotlin"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":19161,"url":"https:\/\/mole-kingdom.com\/wpbl\/2018\/05\/17\/19161.html","url_meta":{"origin":9046,"position":4},"title":"\u3046\u306b\u306e\u30c8\u30b2\u306f\u523a\u3055\u308b\u3068\u75db\u3044(\u00b4\uff65\u03c9\uff65\uff40)-14 : LLM","author":"moleking","date":"2018\u5e745\u670817\u65e5","format":false,"excerpt":"\u203b2018\/05\/19\u8ffd\u8a18 \u30d5\u30a1\u30a4\u30eb\u304c\u5b58\u5728\u3057\u306a\u3044\u5834\u5408\u306bDefaultLanguage\u3092\u958b\u304f\u3088\u3046\u306b\u3059\u308b\u2026","rel":"","context":"C#","block_context":{"text":"C#","link":"https:\/\/mole-kingdom.com\/wpbl\/category\/programming\/csharp"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":22833,"url":"https:\/\/mole-kingdom.com\/wpbl\/2020\/12\/13\/22833.html","url_meta":{"origin":9046,"position":5},"title":"\uff3c\uff7a\uff6f\uff84\uff98\uff5e\uff9d\uff0f","author":"moleking","date":"2020\u5e7412\u670813\u65e5","format":false,"excerpt":"\u30ac\u30c1\u3067\u52c9\u5f37\u3059\u308b\u6c17\u3082\u4f55\u304b\u3092\u4f5c\u308b\u4e88\u5b9a\u3082\u306a\u3044\u3082\u306e\u306e\u3001\u4eca\u5e74\u306f\u4f59\u308a\u306b\u3082\u4f55\u3082\u3057\u306a\u304b\u3063\u305f\u306e\u3067\u3001\u73fe\u5b9f\u9003\u907f\u7684\u306bkotl\u2026","rel":"","context":"kotlin","block_context":{"text":"kotlin","link":"https:\/\/mole-kingdom.com\/wpbl\/category\/programming\/kotlin"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/mole-kingdom.com\/wpbl\/wp-json\/wp\/v2\/posts\/9046","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mole-kingdom.com\/wpbl\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mole-kingdom.com\/wpbl\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mole-kingdom.com\/wpbl\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mole-kingdom.com\/wpbl\/wp-json\/wp\/v2\/comments?post=9046"}],"version-history":[{"count":4,"href":"https:\/\/mole-kingdom.com\/wpbl\/wp-json\/wp\/v2\/posts\/9046\/revisions"}],"predecessor-version":[{"id":25456,"href":"https:\/\/mole-kingdom.com\/wpbl\/wp-json\/wp\/v2\/posts\/9046\/revisions\/25456"}],"wp:attachment":[{"href":"https:\/\/mole-kingdom.com\/wpbl\/wp-json\/wp\/v2\/media?parent=9046"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mole-kingdom.com\/wpbl\/wp-json\/wp\/v2\/categories?post=9046"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mole-kingdom.com\/wpbl\/wp-json\/wp\/v2\/tags?post=9046"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}