Results 1 to 5 of 5

Thread: Renaming files listed at listbox_Code for "Rename" buttom?

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2019

    Renaming files listed at listbox_Code for "Rename" buttom?

    I'm trying to create a little program thats introduce some prefixes into the name of the files that found at a folder.

    The names of files are listed at a Listbox1 and the prefixes are choosed at a several Comboboxes.

    This names of the Listbox1 with the choosed prefixes of the Comboboxes are moved to a Listbox2 pressing a buttom ">>>".
    When all of new names are ready at this Listbox2 will be press a buttom "Rename" and the names of files at the folder will be changed according fixed at the Listbox2.

    All of the Userform is already programmed. I have just problems to build the code for the buttom "Rename".
    In others Words, taking the stipulate names of the Listbox2 and changing the names at the respective files showed before at the Listbox1.

    How i can read the new names of files from a Listbox and introduce to the respective name of file?

    1000 Thanks for your feedbacks in advance!

    Name:  Userform.jpg
Views: 123
Size:  18.6 KB

    Private Sub cmdMoveSelLeft_Click()
        'Variable Declaration
        Dim iCnt As Integer
        'Move Selected Items from Listbox1 to Listbox2
        For iCnt = 0 To Me.ListNewFiles.ListCount - 1
            If Me.ListNewFiles.Selected(iCnt) = True Then
                Dim changedName As String
                changedName = Me.ComboBoxKategorie.Value + "_" + Me.ComboBoxTyp.Value + "_" + Me.ListNewFiles.List(iCnt)
                Me.ListChangedFiles.AddItem changedName
            End If
        For iCnt = Me.ListNewFiles.ListCount - 1 To 0 Step -1
            If Me.ListNewFiles.Selected(iCnt) = True Then
                Me.ListNewFiles.RemoveItem iCnt
            End If
        ComboBoxKategorie = ""
        ComboBoxTyp = ""
        TextBoxEXX = ""
        TextBoxUX = ""
        TextBoxTrakt = ""
        TextBoxGebaude = ""
        TextBoxSpecific = ""
    End Sub
    Private Sub cmdRename_Click()
    Dim Msg, Style, Title, Help, Ctxt, Response, MyString
    Msg = "Möchten Sie fortfahern?"
    Style = vbYesNo + vbQuestion + vbDefaultButton2
    Title = "Bestätigung"
    Help = "DEMO.HLP"
    Ctxt = 1000
    Response = MsgBox(Msg, Style, Title, Help, Ctxt)
    If Response = vbYes Then    ' User chose Yes.
            MsgBox "Die Namen sind angepasst" & vbCrLf
            Unload Me
    End If
    End Sub
    Last edited by Shaggy Hiker; Aug 15th, 2019 at 07:17 PM. Reason: Introducing CODE tags.

Posting Permissions

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


Click Here to Expand Forum to Full Width