Attribute VB_Name = "Module_FormatWord"
Option Explicit
Public Function FormatCertificateWord(path As String) As String
Dim doc As Object
Dim rawText As String
If gWordApp Is Nothing Then
Set gWordApp = CreateObject("[Link]")
[Link] = False
End If
Set doc = [Link](path, ReadOnly:=True)
rawText = [Link]
[Link] False
' ----- Nettoyage -----
rawText = Replace(rawText, vbTab, " ")
rawText = Replace(rawText, Chr(160), " ")
rawText = Replace(rawText, vbCr, vbLf)
rawText = Replace(rawText, vbLf & vbLf, vbLf)
' ----- Normalisation des labels -----
Dim lbl
For Each lbl In Array("Cert_Ref", "Rev", "Cert_Typ", "Status", "Issuer", _
"Issue date", "Issued to", "Equipment", "Component", _
"IEC Standard(s)", "Link")
rawText = Replace(rawText, lbl, lbl & ":")
Next lbl
FormatCertificateWord = rawText
End Function