1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| Private Sub UserForm_Initialize()
'Déclaration des variables
Dim oDoc As Document
Dim pAra As Paragraph
Dim tblListe() As String 'tableau pour le remplissage de la liste
Dim tblTemp() As String 'Tableau temporaire pour la fonction split
Dim intP As Integer 'Entier pour l'index des paragraphes
'Affectation des données aux objets
Set oDoc = Application.Documents.Open("L:\MEMOIRES\Mémoire.docm")
'ActiveDocument.Paragraphs
'redimensionnement du tableau en fonction du nombre de paragraphes
'contenus dans le document
ReDim tblListe(oDoc.Paragraphs.Count, 1)
''Boucle sur le paragraphes du document
'For Each pAra In ActiveDocument.Paragraphs
For intP = 1 To oDoc.Paragraphs.Count
''remplissage du tableau temporaire
tblTemp() = Split(oDoc.Paragraphs(intP).Range.Text, "| ")
'tblTemp() = Split(pAra.Range.Text, "- ")
'' tableau temporaire vers la table de remplissage
tblListe(intP, 0) = tblTemp(0)
'tblListe(intP, 1) = tblTemp(1)
'MsgBox tblListe(intP, 0)
Next intP
'transfert des données vers la liste du UserForm
Me.LstChoix.List = tblListe
'Fermeture et libération des objets
'oDoc.Close
Set oDoc = Nothing
End Sub |
Partager