Attribute VB_Name = "Module_SelectFiles"
'Attribute VB_Name = "Module_SelectFiles"
Option Explicit
Public Sub SelectFiles_Step1()
Dim fd As FileDialog
Dim ws As Worksheet: Set ws = [Link](SHEET_DETECT)
Dim i As Long, path As String
Dim startRow As Long, lastRow As Long
Dim newUnique As Long, duplicates As Long
Dim oneDriveRoot As String
' Initialisation des variables globales
If gFileIndex Is Nothing Then Set gFileIndex =
CreateObject("[Link]")
If gStartRowFiles = 0 Then gStartRowFiles = ROW_FILES_START
' Bo�te de s�lection
Set fd = [Link](msoFileDialogFilePicker)
With fd
.AllowMultiSelect = True
.title = "Select one or more Word certificate files"
.[Link]
.[Link] "Word Documents", "*.doc;*.docx"
On Error Resume Next
oneDriveRoot = Environ$("OneDrive")
If Len(oneDriveRoot) > 0 Then .InitialFileName = oneDriveRoot &
[Link]
On Error GoTo 0
' ---- CAS ANNULATION ----
If .show <> -1 Then
[Link]("B" & ROW_ERR1).value = "No file selected."
[Link]("B" & ROW_ERR2).value = "Existing files will remain active."
' Garder Analyze actif si compteur > 0
If [Link] > 0 Then
UI_ShowAnalyze True
End If
Exit Sub
End If
' S�lection r�elle
Set gSelectedFiles = .SelectedItems
End With
' ---- V�rification s�lection vide ----
If gSelectedFiles Is Nothing Or [Link] = 0 Then
[Link]("B" & ROW_ERR1).value = "No file selected."
[Link]("B" & ROW_ERR2).value = "Please select at least one document."
If [Link] > 0 Then
UI_ShowAnalyze True
End If
Exit Sub
End If
' ---- Ajout des fichiers s�lectionn�s ----
lastRow = [Link]([Link], "B").End(xlUp).Row
startRow = IIf(lastRow < gStartRowFiles, gStartRowFiles, lastRow + 1)
newUnique = 0
duplicates = 0
For i = 1 To [Link]
path = CStr(gSelectedFiles(i))
If Len(path) > 0 Then
If Not [Link](path) Then
[Link] path, True
[Link](startRow, "B").value = path
[Link](startRow, "A").ClearContents ' Reset count
startRow = startRow + 1
newUnique = newUnique + 1
Else
duplicates = duplicates + 1
End If
End If
Next i
' ---- Mise � jour compteur ----
[Link]("B" & ROW_COUNT).value = [Link] & " file(s) selected."
[Link]
[Link]("B" & ROW_ERR1 & ":B" & ROW_ERR2).ClearContents
If duplicates > 0 Then
[Link]("B" & ROW_ERR1).value = duplicates & " duplicate file(s) ignored."
[Link]("B" & ROW_ERR2).value = "Each file is processed only once."
End If
' ---- Afficher Analyze ----
If [Link] > 0 Then
UI_ShowAnalyze True
End If
End Sub