Afficher un message
Vieux 29/10/2005, 11h41   #2 (permalink)
MichelXld
XLDnaute Barbatruc
 
Date d'inscription: février 2005
Messages: 3 816
Par défaut Re:Import arborescence de word vers excel

bonjour

cet exemple permet de recuperer l'arborescence des paragraphes d'un document Word
Chaque paragraphe est supposé débuter par une numérotation


tu dois prealablement activer la reference 'Microsoft Word xx.x Object Library'
dans l'editeur de macros
Menu Outils
References
coches la ligne 'Microsoft Word xx.x Object Library'
cliques sur OK


Sub boucleParagraphesWord()
'necesite d'activer la reference Microsoft Word xx.x Object Library
Dim appWrd As Word.Application
Dim docWord As Word.Document
Dim Paragraphe As Paragraph
Dim i As Integer

Set appWrd = CreateObject('Word.Application')
appWrd.Visible = True
Set docWord = appWrd.Documents.Open('C:\\monDocument.doc')

For Each Paragraphe In docWord.Paragraphs
If Paragraphe.Range.ListFormat.ListValue <> 0 Then
i = i + 1
Cells(i, Paragraphe.Range.ListFormat.ListLevelNumber) = _
Paragraphe.Range.ListFormat.ListString
Cells(i, Paragraphe.Range.ListFormat.ListLevelNumber + 1) = _
Paragraphe.Range.Sentences(1).Text
End If
Next

End Sub



il te restera à adapter la mise en forme pour ton projet


bonne journée
MichelXld
MichelXld est déconnecté   Réponse avec citation