Doflamingo
Board Regular
- Joined
- Apr 16, 2019
- Messages
- 238
Hi all,
Here is the code of the Userform I use
And here is the code to navigate in the files of your laptop
it works with a function from a module
The files appear in Listbox1, and I would like to know how to rename them, when I select one with the combox1 values and the textbox3 values in the code of the userform posted above. But here just a reminder
Any ideas ?
Here is the code of the Userform I use
Code:
If Me.répertoire = "" Then Me.répertoire = ThisWorkbook.Path
nf = Dir(Me.répertoire & "\*.*")
n = 0
Do While nf <> ""
n = n + 1
ReDim Preserve Tbl(1 To n)
Tbl(n) = nf
nf = Dir
Loop
If n > 0 Then Me.ListBox1.List = Tbl
'partie retouchée
Me.TextBox1 = Me.ListBox1.ListCount & IIf(Me.ListBox1.ListCount > 1, " Fichiers", " Fichier")
Me.TypeFich.List = Array("*.*", "*.xls", "*.jpg", "*.mdb", "*.txt", "*.docx", "*.pdf")
'utilisation de la variable Enable_event pour éviter la passage dans l'événement Change
Enable_event = True
Me.TypeFich.ListIndex = 0
Enable_event = False
ComboBox1.Clear
With ComboBox1
.AddItem "PR_"
.AddItem "WC_"
.AddItem "PRegultion_"
.AddItem "BL_"
.AddItem "ID_"
.AddItem "FS_"
textbox3.value = ""
End With
And here is the code to navigate in the files of your laptop
Code:
If Val(Application.Version) >= 10 Then
With Application.FileDialog(msoFileDialogFolderPicker)
.InitialFileName = CurDir()
.Show
If .SelectedItems.Count > 0 Then
Me.répertoire = .SelectedItems(1)
Else
Me.répertoire = ""
End If
ChDir Me.répertoire
UserForm_Initialize
End With
Else
DossierChoisi = VoirDossier("Choisir le dossier")
If DossierChoisi <> "" Then
Me.répertoire = DossierChoisi
End If
ChDir Me.répertoire
UserForm_Initialize
End If
it works with a function from a module
Code:
Private Type BROWSEINFO hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type
Private Declare PtrSafe Function SHGetPathFromIDList Lib "shell32.dll" Alias _
"SHGetPathFromIDListA" (ByVal pidl As Long, _
ByVal pszPath As String) As Long
Private Declare PtrSafe Function SHBrowseForFolder Lib "shell32.dll" Alias _
"SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) _
As Long
Private Const BIF_RETURNONLYFSDIRS = &H1
Public Function VoirDossier(szDialogTitle As String) As String
Dim X As Long, bi As BROWSEINFO, dwIList As Long
Dim szPath As String, wPos As Integer
With bi
.hOwner = hWndAccessApp
.lpszTitle = szDialogTitle
.ulFlags = BIF_RETURNONLYFSDIRS
End With
dwIList = SHBrowseForFolder(bi)
szPath = Space$(512)
X = SHGetPathFromIDList(ByVal dwIList, ByVal szPath)
If X Then
wPos = InStr(szPath, Chr(0))
VoirDossier = Left$(szPath, wPos - 1)
Else
VoirDossier = ""
End If
End Function
The files appear in Listbox1, and I would like to know how to rename them, when I select one with the combox1 values and the textbox3 values in the code of the userform posted above. But here just a reminder
Code:
ComboBox1.Clear With ComboBox1
.AddItem "PR_"
.AddItem "WC_"
.AddItem "PRegultion_"
.AddItem "BL_"
.AddItem "ID_"
.AddItem "FS_"
textbox3.value = ""
Any ideas ?