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

bonjour

j'espere que cette adaptation pourra t'aider

Sub boucleParagraphesWord_V02()
'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 Pr As String
Dim i As Integer
Dim Tableau(2) 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

If Pr <> '' Then Cells(Tableau(0), Tableau(1)) = Pr
Pr = ''
Tableau(0) = i
Tableau(1) = Paragraphe.Range.ListFormat.ListLevelNumber + 2
Else

Pr = Pr & vbLf & Paragraphe.Range.Text
End If
Next Paragraphe
End Sub




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