{"id":35,"date":"2024-09-12T07:04:49","date_gmt":"2024-09-11T23:04:49","guid":{"rendered":"https:\/\/lilia-study.com\/lang\/eng\/?p=35"},"modified":"2024-09-12T07:04:50","modified_gmt":"2024-09-11T23:04:50","slug":"onajifolder","status":"publish","type":"post","link":"https:\/\/lilia-study.com\/lang\/chs\/excel\/excel-vba\/onajifolder\/","title":{"rendered":"Excel VBA \u5c06\u4e66\u7c4d\u4fdd\u5b58\u5728\u540c\u4e00\u6587\u4ef6\u5939\u4e2d"},"content":{"rendered":"<p><!-- wp:html --><\/p>\n<p><span class=\"icon_point color01\"><\/span>&nbsp;\u672c\u6587\u7531\u65e5\u6587\u8bd1\u6210\u4e2d\u6587\u3002<\/p>\n<p><!-- \/wp:html --><\/p>\n\n\n\n\n<p>\u5728\u4f7f\u7528 Excel \u65f6\uff0c\u60a8\u7ecf\u5e38\u5e0c\u671b\u5728\u4e0e\u5f53\u524d\u5de5\u4f5c\u7c3f\u76f8\u540c\u7684\u6587\u4ef6\u5939\u4e2d\u4fdd\u5b58\u4e00\u4e2a\u65b0\u6587\u4ef6\uff0c\u5e76\u4f7f\u7528\u65b0\u540d\u79f0\u3002<\/p>\n\n\n\n<p>\u60a8\u53ef\u80fd\u60f3\u4ece\u59d3\u540d\u5217\u8868\u4e2d\u4e3a\u6bcf\u4e2a\u4eba\u521b\u5efa\u4e00\u4e2a\u6587\u4ef6\uff0c\u6216\u8005\u4e3a\u6bcf\u4e2a\u6708\u6216\u6bcf\u5e74\u521b\u5efa\u4e00\u4e2a\u6587\u4ef6\u3002<\/p>\n\n\n\n<p>\u521b\u5efa\u4e00\u4e2a\u6a21\u677f\u8d26\u7c3f\uff0c\u7136\u540e\u4f7f\u7528\u5b8f\u4e00\u6b21\u5728\u540c\u4e00\u6587\u4ef6\u5939\u4e2d\u521b\u5efa\u591a\u4e2a\u8d26\u7c3f\uff0c\u8fd9\u6837\u505a\u975e\u5e38\u65b9\u4fbf\uff01<\/p>\n\n\n<p><!-- wp:html --><\/p>\n<p style=\"margin-bottom:0;padding-bottom:0;\">&lt;&nbsp;Sponsored Links&nbsp;&gt;<\/p>\n<p><script async=\"\" src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script><br \/>\n<!-- lilia top --><br \/>\n<ins class=\"adsbygoogle\" style=\"display:block\" data-ad-client=\"ca-pub-4504956686889525\" data-ad-slot=\"2727563599\" data-ad-format=\"auto\" data-full-width-responsive=\"true\"><\/ins><br \/>\n<script>\n(adsbygoogle = window.adsbygoogle || []).push({});\n<\/script><br \/>\n<!-- \/wp:html --><\/p>\n\n\n\n\n<h2 class=\"wp-block-heading\">\u5c06\u56fe\u4e66\u547d\u540d\u4fdd\u5b58\u5728\u4e0e\u539f\u59cb\u56fe\u4e66\u76f8\u540c\u7684\u6587\u4ef6\u5939\u4e2d<\/h2>\n\n\n\n<p>\u5c06\u539f\u7248\u4e66\u4f5c\u4e3a \u201c\u542f\u7528\u5b8f\u7684\u4e66 \u201d\u4fdd\u5b58\u5728\u4efb\u610f\u6587\u4ef6\u5939\u4e2d\u3002\u6587\u4ef6\u540d\u4e3a \u201c\u5143\u306e\u30d6\u30c3\u30af.xlsm\u201d\u3002<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/lilia-study.com\/wp-content\/uploads\/2023\/10\/01-3.webp\" alt=\"\u30d6\u30c3\u30af\u4fdd\u5b58\" class=\"wp-image-4179\"\/><\/figure>\n<\/div>\n\n\n<p>\u3000<\/p>\n\n\n\n<p>\u5728\u539f\u4e66\u7684 VBE \u4e2d\u5199\u51fa\u4ee5\u4e0b\u5185\u5bb9<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers cbp-highlight-hover\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:1.5rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#000000;--cbp-line-number-width:calc(1 * 0.6 * 1.5rem);--cbp-line-highlight-color:rgba(0, 0, 0, 0.2);line-height:1.8rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" data-code=\"Sub SameFolderSave()\n    '\u58f0\u660e\u53d8\u91cf\uff08\u7528\u4e8e\u5728\u56fe\u4e66\u4e2d\u5b58\u50a8\u6587\u4ef6\u5939\u540d\u79f0\uff09\n    Dim thisPath As String\n    '\u5728\u53d8\u91cf\u4e2d\u8f93\u5165\u56fe\u4e66\u7684\u6587\u4ef6\u5939\u540d\u79f0\u3002\n    thisPath = ThisWorkbook.Path\n    '\u7528\u4e0d\u540c\u7684\u540d\u79f0\u5c06\u6b64\u4e66\u4fdd\u5b58\u5728\u540c\u4e00\u6587\u4ef6\u5939\u4e2d\n    ThisWorkbook.SaveAs Filename:=thisPath &amp; &quot;\\\u65b0\u3057\u3044\u30d6\u30c3\u30af.xlsm&quot;\nEnd Sub\" style=\"color:#000000;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki light-plus\" style=\"background-color: #FFFFFF\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #0000FF\">Sub<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #795E26\">SameFolderSave<\/span><span style=\"color: #000000\">()<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    <\/span><span style=\"color: #008000\">&#39;\u58f0\u660e\u53d8\u91cf\uff08\u7528\u4e8e\u5728\u56fe\u4e66\u4e2d\u5b58\u50a8\u6587\u4ef6\u5939\u540d\u79f0\uff09<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    <\/span><span style=\"color: #0000FF\">Dim<\/span><span style=\"color: #001080\"> thisPath <\/span><span style=\"color: #000000\">As <\/span><span style=\"color: #267F99\">String<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    <\/span><span style=\"color: #008000\">&#39;\u5728\u53d8\u91cf\u4e2d\u8f93\u5165\u56fe\u4e66\u7684\u6587\u4ef6\u5939\u540d\u79f0\u3002<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    <\/span><span style=\"color: #001080\">thisPath<\/span><span style=\"color: #000000\"> = ThisWorkbook.Path<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    <\/span><span style=\"color: #008000\">&#39;\u7528\u4e0d\u540c\u7684\u540d\u79f0\u5c06\u6b64\u4e66\u4fdd\u5b58\u5728\u540c\u4e00\u6587\u4ef6\u5939\u4e2d<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    ThisWorkbook.SaveAs <\/span><span style=\"color: #267F99\">Filename<\/span><span style=\"color: #000000\">:=<\/span><span style=\"color: #001080\">thisPath<\/span><span style=\"color: #000000\"> &amp; <\/span><span style=\"color: #A31515\">&quot;\\\u65b0\u3057\u3044\u30d6\u30c3\u30af.xlsm&quot;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #0000FF\">End Sub<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u3000<\/p>\n\n\n\n<p>\u6267\u884c\u7f16\u5199\u7684 VBA \u540e\uff0c\u5728\u540c\u4e00\u6587\u4ef6\u5939\u4e2d\u521b\u5efa\u4e86\u4e00\u4e2a\u540d\u4e3a \u201c\u65b0\u3057\u3044\u30d6\u30c3\u30af.xlsm \u201d\u7684\u6587\u4ef6\u3002<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/lilia-study.com\/wp-content\/uploads\/2023\/10\/02-3.webp\" alt=\"\u30de\u30af\u30ed\u3067\u65b0\u3057\u3044\u30d6\u30c3\u30af\u4fdd\u5b58\" class=\"wp-image-4180\"\/><\/figure>\n<\/div>\n\n\n<p>\u3000<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5728\u540c\u4e00\u6587\u4ef6\u5939\u4e2d\u4fdd\u5b58\u591a\u672c\u4e66<\/h2>\n\n\n\n<p>\u5982\u679c\u60a8\u60f3\u4fdd\u5b58\u591a\u672c\u4e66\uff0c\u8bf7\u91cd\u590d\u6b64\u8fc7\u7a0b\u3002<\/p>\n\n\n\n<p>\u5728\u539f\u4e66\u7684 VBE \u4e2d\u5199\u5165\u4ee5\u4e0b\u5185\u5bb9\u3002<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers cbp-highlight-hover\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:1.5rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#000000;--cbp-line-number-width:calc(2 * 0.6 * 1.5rem);--cbp-line-highlight-color:rgba(0, 0, 0, 0.2);line-height:1.8rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" data-code=\"Sub SameFolderSave()\n    '\u53d8\u91cf\u58f0\u660e\n    Dim thisPath As String     '\u6587\u4ef6\u5939\u540d\u79f0\n    Dim i As Long              '\u8fed\u4ee3\u5904\u7406\n\n    \n    '\u81ea\u5206\u306e\u30d6\u30c3\u30af\u306e\u30d5\u30a9\u30eb\u30c0\u540d\u3092\u5909\u6570\u306b\u5165\u308c\u308b\n    thisPath = ThisWorkbook.Path\n    \n    '\u5728\u53d8\u91cf\u4e2d\u8f93\u5165\u56fe\u4e66\u7684\u6587\u4ef6\u5939\u540d\u79f0\u3002\n    For i = 1 To 10\n        ThisWorkbook.SaveAs Filename:=thisPath &amp; &quot;\\\u65b0\u3057\u3044\u30d6\u30c3\u30af&quot; &amp; i &amp; &quot;.xlsm&quot;\n    Next i\nEnd Sub\" style=\"color:#000000;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki light-plus\" style=\"background-color: #FFFFFF\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #0000FF\">Sub<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #795E26\">SameFolderSave<\/span><span style=\"color: #000000\">()<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    <\/span><span style=\"color: #008000\">&#39;\u53d8\u91cf\u58f0\u660e<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    <\/span><span style=\"color: #0000FF\">Dim<\/span><span style=\"color: #001080\"> thisPath <\/span><span style=\"color: #000000\">As <\/span><span style=\"color: #267F99\">String<\/span><span style=\"color: #000000\">     <\/span><span style=\"color: #008000\">&#39;\u6587\u4ef6\u5939\u540d\u79f0<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    <\/span><span style=\"color: #0000FF\">Dim<\/span><span style=\"color: #001080\"> i <\/span><span style=\"color: #000000\">As <\/span><span style=\"color: #267F99\">Long<\/span><span style=\"color: #000000\">              <\/span><span style=\"color: #008000\">&#39;\u8fed\u4ee3\u5904\u7406<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    <\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    <\/span><span style=\"color: #008000\">&#39;\u81ea\u5206\u306e\u30d6\u30c3\u30af\u306e\u30d5\u30a9\u30eb\u30c0\u540d\u3092\u5909\u6570\u306b\u5165\u308c\u308b<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    <\/span><span style=\"color: #001080\">thisPath<\/span><span style=\"color: #000000\"> = ThisWorkbook.Path<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    <\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    <\/span><span style=\"color: #008000\">&#39;\u5728\u53d8\u91cf\u4e2d\u8f93\u5165\u56fe\u4e66\u7684\u6587\u4ef6\u5939\u540d\u79f0\u3002<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    <\/span><span style=\"color: #AF00DB\">For<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #001080\">i<\/span><span style=\"color: #000000\"> = <\/span><span style=\"color: #098658\">1<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #AF00DB\">To<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #098658\">10<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">        ThisWorkbook.SaveAs <\/span><span style=\"color: #267F99\">Filename<\/span><span style=\"color: #000000\">:=<\/span><span style=\"color: #001080\">thisPath<\/span><span style=\"color: #000000\"> &amp; <\/span><span style=\"color: #A31515\">&quot;\\\u65b0\u3057\u3044\u30d6\u30c3\u30af&quot;<\/span><span style=\"color: #000000\"> &amp;<\/span><span style=\"color: #001080\"> i<\/span><span style=\"color: #000000\"> &amp; <\/span><span style=\"color: #A31515\">&quot;.xlsm&quot;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    <\/span><span style=\"color: #AF00DB\">Next<\/span><span style=\"color: #000000\"> i<\/span><\/span>\n<span class=\"line\"><span style=\"color: #0000FF\">End Sub<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u3000<\/p>\n\n\n\n<p>\u5f53\u6211\u8fd0\u884c\u7f16\u5199\u7684 VBA \u65f6\uff0c\u5728\u540c\u4e00\u4e2a\u6587\u4ef6\u5939\u4e2d\u521b\u5efa\u4e86 10 \u4e2a\u6587\u4ef6\u3002<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/lilia-study.com\/wp-content\/uploads\/2023\/10\/03-3.webp\" alt=\"\u30de\u30af\u30ed\u3067\u65b0\u3057\u3044\u30d6\u30c3\u30af\u3092\u8907\u6570\u4fdd\u5b58\" class=\"wp-image-4181\"\/><\/figure>\n<\/div>\n\n\n<p>\u3000<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u6837\u54c1<\/h2>\n\n\n\n<p>\u6211\u6b63\u5728\u4f7f\u7528 VBA \u5236\u4f5c\u4e00\u4e2a\u6837\u672c\uff0c\u4fdd\u5b58\u5728\u540c\u4e00\u4e2a\u6587\u4ef6\u5939\u4e2d\u3002<\/p>\n\n\n\n<p><a href=\"https:\/\/lilia-study.com\/excel\/vba-sample\/fso-nippou-geppou.html\" target=\"_blank\" rel=\"noreferrer noopener\">VBA\u3067\u540c\u3058\u30d5\u30a9\u30eb\u30c0\u5185\u306e\u30d6\u30c3\u30af\u306e\u30c7\u30fc\u30bf\u3092\u4e00\u3064\u306e\u30d6\u30c3\u30af\u306b\u96c6\u8a08\u3059\u308b<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/lilia-study.com\/excel\/vba-sample\/kojin-book.html\" target=\"_blank\" rel=\"noreferrer noopener\">VBA\u3067\u540d\u7c3f\u304b\u3089\u500b\u4eba\u6bce\u306e\u30d6\u30c3\u30af\u3092\u4f5c\u308b<\/a><\/p>\n\n\n\n<p>\u3000<\/p>\n\n\n<p><!-- wp:html --><\/p>\n<p style=\"margin-bottom:0;padding-bottom:0;\">&lt;&nbsp;Sponsored Links&nbsp;&gt;<\/p>\n<p><script async src=\"https:\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js?client=ca-pub-4504956686889525\"\n     crossorigin=\"anonymous\"><\/script><br \/>\n<!-- lilia bottom --><br \/>\n<ins class=\"adsbygoogle\"\n     style=\"display:inline-block;width:336px;height:280px\"\n     data-ad-client=\"ca-pub-4504956686889525\"\n     data-ad-slot=\"7848928897\"><\/ins><br \/>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script><br \/>\n<!-- \/wp:html --><\/p>\n\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u4f7f\u7528 Excel \u65f6\uff0c\u60a8\u7ecf\u5e38\u5e0c\u671b\u5728\u4e0e\u5f53\u524d\u5de5\u4f5c\u7c3f\u76f8\u540c\u7684\u6587\u4ef6\u5939\u4e2d\u4fdd\u5b58\u4e00\u4e2a\u65b0\u6587\u4ef6\uff0c\u5e76\u4f7f\u7528\u65b0\u540d\u79f0\u3002 \u60a8\u53ef\u80fd\u60f3\u4ece\u59d3\u540d\u5217\u8868\u4e2d\u4e3a\u6bcf\u4e2a\u4eba\u521b\u5efa\u4e00\u4e2a\u6587\u4ef6\uff0c\u6216\u8005\u4e3a\u6bcf\u4e2a\u6708\u6216\u6bcf\u5e74\u521b\u5efa\u4e00\u4e2a\u6587\u4ef6\u3002 \u521b\u5efa\u4e00\u4e2a\u6a21\u677f\u8d26\u7c3f\uff0c\u7136\u540e\u4f7f\u7528\u5b8f\u4e00\u6b21\u5728\u540c\u4e00\u6587\u4ef6\u5939\u4e2d\u521b\u5efa [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,2],"tags":[],"class_list":{"0":"post-35","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-excel","7":"category-excel-vba"},"_links":{"self":[{"href":"https:\/\/lilia-study.com\/lang\/chs\/wp-json\/wp\/v2\/posts\/35","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lilia-study.com\/lang\/chs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lilia-study.com\/lang\/chs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lilia-study.com\/lang\/chs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lilia-study.com\/lang\/chs\/wp-json\/wp\/v2\/comments?post=35"}],"version-history":[{"count":0,"href":"https:\/\/lilia-study.com\/lang\/chs\/wp-json\/wp\/v2\/posts\/35\/revisions"}],"wp:attachment":[{"href":"https:\/\/lilia-study.com\/lang\/chs\/wp-json\/wp\/v2\/media?parent=35"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lilia-study.com\/lang\/chs\/wp-json\/wp\/v2\/categories?post=35"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lilia-study.com\/lang\/chs\/wp-json\/wp\/v2\/tags?post=35"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}