以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]求改管理文件代码  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=89804)

--  作者:jyh7081
--  发布时间:2016/8/30 12:40:00
--  [求助]求改管理文件代码
我有一段execl中的VBA代码,是以“-”作为分界,将含有相同字符串文件名的文档,放入相同文件夹中。我想把这段代码运用到foxtable中,原代码如下:

Sub 文件管理()
    Dim MyPath$, MyName$, DestinationPath$, arr(), i&, m&
    MyPath = ThisWorkbook.Path & "\\文件\\"
    MyName = Dir(MyPath & "*.doc")
    Do While MyName <> ""
        m = m + 1
        ReDim Preserve arr(1 To m)
        arr(m) = MyName
        MyName = Dir
    Loop
    For i = 1 To m
        DestinationPath = MyPath & Split(arr(i), "-")(0)
        If LenB(Dir(DestinationPath, 16)) = 0 Then MkDir DestinationPath
        FileCopy MyPath & arr(i), DestinationPath & "\\" & arr(i)
    Next
End Sub

我修改的代码见斜体字,还需要怎样改动:

   Dim App As New MSExcel.Application
   App.Visible = False

   Dim MyPath$, MyName$, DestinationPath$, arr(), i&, m&
    MyPath = ProjectPath & "\\文件\\"
    MyName = Dir(MyPath & "*.doc")
    Do While MyName <> ""
        m = m + 1
        ReDim Preserve arr(1 To m)
        arr(m) = MyName
        MyName = Dir
    Loop
    For i = 1 To m
        DestinationPath = MyPath & Split(arr(i), "-")(0)
        If LenB(Dir(DestinationPath, 16)) = 0 Then MkDir DestinationPath
        FileCopy MyPath & arr(i), DestinationPath & "\\" & arr(i)
    Next




--  作者:Hyphen
--  发布时间:2016/8/30 14:32:00
--  
还是使用狐表的文件管理类吧