{"id":200,"date":"2024-11-21T23:10:49","date_gmt":"2024-11-21T14:10:49","guid":{"rendered":"https:\/\/anbtksh.com\/?p=200"},"modified":"2024-11-21T23:10:51","modified_gmt":"2024-11-21T14:10:51","slug":"%e6%8c%87%e5%ae%9a%e3%81%97%e3%81%9f%e3%83%95%e3%82%a9%e3%83%ab%e3%83%80%e3%83%91%e3%82%b9%e5%86%85%e3%81%ae%e5%85%a8%e3%82%a8%e3%82%af%e3%82%bb%e3%83%ab%e3%82%b7%e3%83%bc%e3%83%88%e4%b8%8a%e3%81%ae","status":"publish","type":"post","link":"https:\/\/anbtksh.com\/?p=200","title":{"rendered":"\u6307\u5b9a\u3057\u305f\u30d5\u30a9\u30eb\u30c0\u30d1\u30b9\u5185\u306e\u5168\u30a8\u30af\u30bb\u30eb\u30b7\u30fc\u30c8\u4e0a\u306e\u30b7\u30a7\u30a4\u30d7\u306e\u30c6\u30ad\u30b9\u30c8\u3092\u51fa\u529b"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Sub \u30b7\u30a7\u30a4\u30d7\u306e\u30c6\u30ad\u30b9\u30c8\u4e00\u89a7A()<br>Dim ws As Worksheet<br>Dim outputWs As Worksheet<br>Dim targetShape As shape<br>Dim row As Long<br>Dim folderPath As String<br>Dim fileName As String<br>Dim targetWb As Workbook<br>Dim newWb As Workbook<br>Dim fso As Object<br>Dim outputFilePath As String<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>' \u30d5\u30a9\u30eb\u30c0\u306e\u30d5\u30eb\u30d1\u30b9\u3092\u53d6\u5f97\nfolderPath = InputBox(\"\u4f5c\u696d\u7528\u30d5\u30a9\u30eb\u30c0\u306e\u30d5\u30eb\u30d1\u30b9\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\", \"\u30d5\u30a9\u30eb\u30c0\u306e\u9078\u629e\")\nIf folderPath = \"\" Then\n    MsgBox \"\u30d5\u30a9\u30eb\u30c0\u306e\u30d1\u30b9\u304c\u5165\u529b\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002\"\n    Exit Sub\nEnd If\nIf Right(folderPath, 1) &lt;&gt; \"\\\" Then folderPath = folderPath &amp; \"\\\"\n\noutputFilePath = folderPath &amp; \"\u30b7\u30a7\u30a4\u30d7\u306e\u30c6\u30ad\u30b9\u30c8\u4e00\u89a7.xlsx\"\n\n' \u30b7\u30a7\u30a4\u30d7\u306e\u30c6\u30ad\u30b9\u30c8\u4e00\u89a7.XLSX \u30d5\u30a1\u30a4\u30eb\u3092\u524a\u9664\nSet fso = CreateObject(\"Scripting.FileSystemObject\")\nIf fso.FileExists(outputFilePath) Then\n    fso.DeleteFile outputFilePath\nEnd If\n\n' \u30d5\u30a9\u30eb\u30c0\u5185\u306e\u5168\u3066\u306e\u30a8\u30af\u30bb\u30eb\u30d5\u30a1\u30a4\u30eb\u3092\u958b\u304f\nfileName = Dir(folderPath &amp; \"*.xlsx\")\n\n' \u65b0\u3057\u3044\u30d6\u30c3\u30af\u3092\u4f5c\u6210\nSet newWb = Workbooks.Add\n' \u7d50\u679c\u3092\u51fa\u529b\u3059\u308b\u65b0\u3057\u3044\u30b7\u30fc\u30c8\u3092\u4f5c\u6210\nSet outputWs = newWb.sheets(1)\noutputWs.Name = \"\u30b7\u30a7\u30a4\u30d7\u306e\u30c6\u30ad\u30b9\u30c8\u4e00\u89a7\"\n\n' \u898b\u51fa\u3057\u3092\u8a2d\u5b9a\noutputWs.Cells(1, 1).Value = \"\u30d6\u30c3\u30af\u540d\"\noutputWs.Cells(1, 2).Value = \"\u30b7\u30fc\u30c8\u540d\"\noutputWs.Cells(1, 3).Value = \"\u30b0\u30eb\u30fc\u30d7\u540d\"\noutputWs.Cells(1, 4).Value = \"\u30b7\u30a7\u30a4\u30d7\u540d\"\noutputWs.Cells(1, 5).Value = \"\u30c6\u30ad\u30b9\u30c8\"\n\n' \u898b\u51fa\u3057\u306e\u66f8\u5f0f\u8a2d\u5b9a\nWith outputWs.Range(\"A1:E1\")\n    .Interior.Color = RGB(255, 255, 0) ' \u80cc\u666f\u3092\u9ec4\u8272\u306b\u8a2d\u5b9a\n    .HorizontalAlignment = xlCenter ' \u30bb\u30f3\u30bf\u30ea\u30f3\u30b0\n    .Font.Bold = True\nEnd With\n\nrow = 2\n\nDo While fileName &lt;&gt; \"\"\n    Set targetWb = Workbooks.Open(folderPath &amp; fileName)\n\n    ' \u5404\u30ef\u30fc\u30af\u30b7\u30fc\u30c8\u3092\u30eb\u30fc\u30d7\n    For Each ws In targetWb.Worksheets\n        ' \u5404\u30b7\u30a7\u30a4\u30d7\u3092\u30eb\u30fc\u30d7\n        For Each targetShape In ws.Shapes\n            Call \u30b7\u30a7\u30a4\u30d7\u306e\u30c6\u30ad\u30b9\u30c8\u4e00\u89a7A_1(targetShape, outputWs, row, \"\", ws.Name, fileName)\n        Next targetShape\n    Next ws\n\n    targetWb.Close False\n    fileName = Dir\nLoop\n\n' \u30bb\u30eb\u5e45\u3092\u6700\u9069\u5316\noutputWs.columns(\"A:E\").AutoFit\n\n' \u65b0\u3057\u3044\u30d5\u30a1\u30a4\u30eb\u306b\u4fdd\u5b58\uff08\u65e2\u5b58\u30d5\u30a1\u30a4\u30eb\u304c\u3042\u308c\u3070\u4e0a\u66f8\u304d\uff09\nOn Error GoTo SaveError\nApplication.DisplayAlerts = False\nnewWb.SaveAs fileName:=outputFilePath, FileFormat:=xlOpenXMLWorkbook\nApplication.DisplayAlerts = True\nOn Error GoTo 0\n\nMsgBox \"\u30d5\u30a1\u30a4\u30eb\u306f\u6b63\u5e38\u306b\u4fdd\u5b58\u3055\u308c\u307e\u3057\u305f\u3002\"\nExit Sub<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">SaveError:<br>MsgBox &#8220;\u30d5\u30a1\u30a4\u30eb\u3092\u4fdd\u5b58\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u30a8\u30e9\u30fc: &#8221; &amp; Err.Description<br>Application.DisplayAlerts = True<br>End Sub<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Sub \u30b7\u30a7\u30a4\u30d7\u306e\u30c6\u30ad\u30b9\u30c8\u4e00\u89a7A_1(targetShape As shape, outputWs As Worksheet, ByRef row As Long, groupName As String, sheetName As String, bookName As String)<br>Dim i As Long<br>Dim shapeName As String<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>shapeName = targetShape.Name\n\n' \u30b0\u30eb\u30fc\u30d7\u5316\u3055\u308c\u305f\u30b7\u30a7\u30a4\u30d7\u306e\u5834\u5408\nIf targetShape.Type = msoGroup Then\n    For i = 1 To targetShape.GroupItems.Count\n        Call \u30b7\u30a7\u30a4\u30d7\u306e\u30c6\u30ad\u30b9\u30c8\u4e00\u89a7A_1(targetShape.GroupItems(i), outputWs, row, shapeName, sheetName, bookName)\n    Next i\nElse\n    ' \u30c6\u30ad\u30b9\u30c8\u304c\u3042\u308b\u5834\u5408\n    If targetShape.TextFrame2.HasText Then\n        outputWs.Cells(row, 1).Value = bookName\n        outputWs.Cells(row, 2).Value = sheetName\n        outputWs.Cells(row, 3).Value = groupName\n        outputWs.Cells(row, 4).Value = shapeName\n        outputWs.Cells(row, 5).Value = targetShape.TextFrame2.textRange.Text\n        row = row + 1\n    End If\nEnd If<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">End Sub<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sub \u30b7\u30a7\u30a4\u30d7\u306e\u30c6\u30ad\u30b9\u30c8\u4e00\u89a7A()Dim ws As WorksheetDim outputWs As WorksheetDim targetShape As shapeDim row As LongDim folde &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/anbtksh.com\/?p=200\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;\u6307\u5b9a\u3057\u305f\u30d5\u30a9\u30eb\u30c0\u30d1\u30b9\u5185\u306e\u5168\u30a8\u30af\u30bb\u30eb\u30b7\u30fc\u30c8\u4e0a\u306e\u30b7\u30a7\u30a4\u30d7\u306e\u30c6\u30ad\u30b9\u30c8\u3092\u51fa\u529b&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-200","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/anbtksh.com\/index.php?rest_route=\/wp\/v2\/posts\/200","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/anbtksh.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/anbtksh.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/anbtksh.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/anbtksh.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=200"}],"version-history":[{"count":1,"href":"https:\/\/anbtksh.com\/index.php?rest_route=\/wp\/v2\/posts\/200\/revisions"}],"predecessor-version":[{"id":201,"href":"https:\/\/anbtksh.com\/index.php?rest_route=\/wp\/v2\/posts\/200\/revisions\/201"}],"wp:attachment":[{"href":"https:\/\/anbtksh.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=200"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/anbtksh.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=200"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/anbtksh.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=200"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}