VBA 拷貝資料夾下的所有檔案到乙個新的資料夾下

2021-09-29 20:18:44 字數 599 閱讀 1518

把**中path下的檔案複製到afterpath目錄下

sub

copyfiles

(path

as string, afterpath)

'path:原資料夾路徑;afterpath:目標資料夾路徑

dimspath

as string

'下邊的我自己也不是很理解,但是效果達成是莫得問題的...

...set fs =

createobject

("scripting.filesystemobject"

) spath =

dir(path, vbdirectory)

dowhile

len(spath)

if spath <

>

"."and spath <

>

".."

then

fs.copyfolder path, afterpath

spath =

dir(

)end

ifloop

end sub

vba開啟關閉資料夾下的所有檔案

因為自己昨天想不通,在路上想了一會兒,今天過來一會兒就想明白了,看來做事還是講效率比較好,磨時間沒意義 sub dakaiguanbi 這個 就是進行二次後處理並生成建立新的excel dim str as string 這個vba 是後處理的 載入階段未接觸上進行修正 dim wb as work...

VBA刪除某些資料夾下的所有檔案

寫完就發現這個 不用寫得這麼重複的 sub shanchuwenjian dim str as string dim str2 as string 這個vba 是後處理的 載入階段未接觸上進行修正 dim i,jj,kk as integer dim wb as workbook for i 1 t...

遍歷資料夾下所有檔案

對於遍歷資料夾來說,其實並不麻煩,使用file轉化位址物件,再用file組獲取內容,其實google都差不多做好了,我就懶得廢話了,直接上 public listlist new arraylist 遍歷所有檔案 public listgetfilelist string path else ret...