Office中国论坛/Access中国论坛

标题: 查找文件及复制移动 [打印本页]

作者: cjssxo    时间: 2012-7-19 05:49
标题: 查找文件及复制移动
在窗体文本框中输入一个值,在文件夹1中模糊查找,如果存在则复制到文件夹2中.见附件

[attach]49702[/attach]
作者: yehf    时间: 2012-7-19 10:10
Private Sub cmd0_Click()


    Dim dirname As String
    Dim mypath As String


    mypath = CurrentProject.Path & "\"
    dirname = Dir(mypath & "文件夹1\*" & Me.txt0 & "*.fsy")

    If dirname = "" Then GoTo Noexits
    Do While dirname <> ""
            Name mypath & "文件夹1\" & dirname As mypath & "文件夹2\" & dirname
        dirname = Dir
    Loop


    MsgBox "文件移动完成!"
    Exit Sub

Noexits:
    MsgBox "找不到你输入的文件"

End Sub

作者: cjssxo    时间: 2012-7-21 17:46
旅游才回来,谢谢yehf.
作者: wufeng980114    时间: 2012-9-18 21:28
不错,学习了
作者: pyh512    时间: 2016-5-4 22:58
我是想批量复制文件夹1中的所有文件到文件夹2中,能帮我写段来参考不?




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3