0% found this document useful (0 votes)
3 views2 pages

Verify Labels in Formatted Files

The document outlines a VBA module for verifying and normalizing labels in formatted files. It includes a subroutine that opens each file, reads and normalizes the text, and saves the changes while providing feedback on the process. An error handling mechanism is also included to alert the user in case of issues during the verification process.

Uploaded by

Majdi Belguith
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Verify Labels in Formatted Files

The document outlines a VBA module for verifying and normalizing labels in formatted files. It includes a subroutine that opens each file, reads and normalizes the text, and saves the changes while providing feedback on the process. An error handling mechanism is also included to alert the user in case of issues during the verification process.

Uploaded by

Majdi Belguith
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

Attribute VB_Name = "Module_VerifyLabels"

Option Explicit

' ======= ETAPE 3 : VERIFICATION DES LIBELL�S =======


Public Sub VerifyLabels_Step3()
gCurrentStep = 3

Dim i As Long, wdDoc As Object, text As String, normalized As String


Dim dummyCount As Long

If IsEmpty(gFormattedFiles) Then
UI_SetNote "No formatted files found.", "STEP 3 - Aborted"
Exit Sub
End If

On Error GoTo Handler

For i = LBound(gFormattedFiles) To UBound(gFormattedFiles)


' Ouvrir le document
Set wdDoc = [Link](gFormattedFiles(i))

' Lire le texte


text = [Link]

' Normaliser le texte (labels)


normalized = BuildNormalizedText(text, dummyCount)

' R��crire le contenu


[Link]
[Link] normalized

' Sauvegarder et fermer


[Link]
[Link] False

' Feedback progression


UI_SetNote "Verifying labels: " & i & " / " & UBound(gFormattedFiles),
"STEP 3 - In progress"
DoEvents
Next i

' Message final


UI_SetNote "Label verification completed for all formatted files.", "STEP 3 -
Done"
UI_ShowNext True
Exit Sub

Handler:
MsgBox "Error during label verification: " & [Link], vbExclamation
End Sub

' ======= Fonction de normalisation =======


Private Function BuildNormalizedText(ByVal srcText As String, ByRef countLabels As
Long) As String
' Exemple simple : supprimer espaces multiples et uniformiser les libell�s
Dim cleaned As String
cleaned = Replace(srcText, vbCrLf, vbLf)
cleaned = Replace(cleaned, vbCr, vbLf)
cleaned = Trim(cleaned)

' TODO : Ajouter logique pour v�rifier et corriger les libell�s


countLabels = 0 ' Placeholder
BuildNormalizedText = cleaned
End Function

You might also like