FrmRename

Userform to switch names of two files.
Basically renaming two files with each other name after user selects those two files from list of files.
You need to download zip in addition to functions below.

CodeFunctionName
What is this?

Public

Tested

Original Work
Sub ToggleRenameFiles_ShowForm(List_Of_Files, Optional Sepa = "|")
    ' Rename files = toggle two files to be renamed
    '
    PDFList = List_Of_Files ' filenames only, no path ' ActiveCell.Value
    FrmRename.Lst1.Clear
    X1 = 0
    For Each PDD In Split(PDFList, Sepa)
        If PDD > "" Then
            FrmRename.Lst1.AddItem PDD
            X1 = X1 + 1
            If X1 < 3 Then FrmRename.Lst1.Selected(X1 - 1) = True
        End If
    Next
    FrmRename.Show
End Sub
Sub ToggleRenameFiles_Rename()
    ' Called by "CmdRen2_Click()" in FrmRename
    ' Only two files expcted to be selected out of list of files listbox
    '
    ImgFol_2 = "D:\Folder\To files\from list above\"
    File1 = ""
    File2 = ""
    For i = 1 To FrmRename.Lst1.ListCount
        If FrmRename.Lst1.Selected(i - 1) Then
            If File1 > "" Then
                If File2 > "" Then
                    Exit For
                Else
                    File2 = FrmRename.Lst1.List(i - 1)
                    Exit For
                End If
            Else
                File1 = FrmRename.Lst1.List(i - 1)
            End If
        End If
    Next
    If File1 = "" Or File2 = "" Then Exit Sub
    ' Rename them
    File01 = ImgFol_2 & File1
    File02 = ImgFol_2 & File2
    File03 = ImgFol_2 & "teeemp.pdf"
    DoEvents
    Name File01 As File03
    DoEvents
    Name File02 As File01
    DoEvents
    Name File03 As File02
End Sub

List_Of_Files, Optional Sepa = "|"

Views 155

Downloads 53

CodeID
DB ID