Results 1 to 9 of 9

move files to another folder delete original

Threaded View

  1. #1
    Valued Forum Contributor
    Join Date
    05-14-2009
    Location
    gold coast
    MS-Off Ver
    Excel 2007
    Posts
    843

    move files to another folder delete original

    hello.

    i would like to be able to move files from one folder to another then delete the original files.
    I dont think im passsing the variables to the functions corectly.
    been trying this for a while now and cant get it.

    Sub Move_DeleteFiles()
    Dim var_File
    Dim int_FileCount As Integer
    Dim str_FileName As String
    Dim str_FileExt As String
    Dim str_FileNameExt As String
    
    var_File = Application.GetOpenFilename _
    (Title:="Please select the Files you wish to import.", _
    MultiSelect:=True)
    
            If IsArray(var_File) Then
                For int_FileCount = 1 To UBound(var_File)
                str_FileName = ExtractFileName(var_File(int_FileCount))
                str_FileExt = GetFileType(var_File(int_FileCount))
                str_FileNameExt = str_FileName & str_FileExt
                    FileCopy var_File, _
                    ("C:\Documents and Settings\1 1\Desktop\Test2\" & str_FileNameExt)
                Next int_FileCount
            End If
            
    'Kill var_File
    End Sub
    
    Function ExtractFileName(var_File As String) As String
    ' extract filename portion of filename, no extension
    Dim str_FileName As String
    
    str_FileName = Right(filename, Len(var_File(int_FileCount)) - InStrRev(var_File(int_FileCount), "\"))
    str_FileName = Replace(fileN, GetFileType(str_FileName), "")
    
    ExtractFileName = str_FileName
    
    End Function
    
    Function GetFileType(var_File As String) As String
    ' get file extension
    GetFileType = Mid$(var_File(int_FileCount), InStrRev(var_File(int_FileCount), "."), Len(var_File(int_FileCount)))
    
    End Function
    and help would greatly be appresated.

    cheers
    Last edited by D_Rennie; 09-09-2009 at 12:05 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1