IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Word Discussion :

Trouver un tableau à partir du titre qui le précède


Sujet :

Word

  1. #1
    Membre à l'essai
    Profil pro
    Inscrit en
    Mai 2005
    Messages
    19
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2005
    Messages : 19
    Points : 11
    Points
    11
    Par défaut Trouver un tableau à partir du titre qui le précède
    Salut à vous

    En VBA, je dois retrouver un tableau dans un document word à partir du titre qui est juste au dessus.

    J'aimerai pouvoir récupérer le numero du tableau pour le manipuler avec ActiveDocument.Tables(i).Cell(j, k).Range pour récupérer son contenu.

    merci !

  2. #2
    Rédacteur/Modérateur

    Avatar de Heureux-oli
    Homme Profil pro
    Contrôleur d'industrie
    Inscrit en
    Février 2006
    Messages
    21 087
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 59
    Localisation : Belgique

    Informations professionnelles :
    Activité : Contrôleur d'industrie
    Secteur : Aéronautique - Marine - Espace - Armement

    Informations forums :
    Inscription : Février 2006
    Messages : 21 087
    Points : 42 926
    Points
    42 926
    Par défaut
    Le titre, tu recherches un mot dans le titre je suppose.

  3. #3
    Membre à l'essai
    Profil pro
    Inscrit en
    Mai 2005
    Messages
    19
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2005
    Messages : 19
    Points : 11
    Points
    11
    Par défaut Résolu
    Bon en fait j'ai résolu mon problème

    Voici la solution :


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
     
        Dim Paragraphe As Paragraph
        Dim MyPara As Paragraph
        Dim myTable As Table
        Dim myTitle As String
     
        myTitle = "Mon titre au dessus du tableau que je cherche"
     
        ' Finds the table in the document from the title above
        For Each Paragraphe In ActiveDocument.Paragraphs
            ' Means that the paragraph is numbered, so it's a title
            If Paragraphe.Range.ListFormat.ListValue <> 0 Then
                ' The first title's sentence is logically the name of the title...
                If InStr(Paragraphe.Range.Sentences(1).Text, myTitle) <> 0 Then
                    ' Finds the first next paragraph with a table
                    Set MyPara = Paragraphe
                    Do
                        Set MyPara = MyPara.Next
                    Loop While MyPara.Next.Range.Tables.Count = 0
                    Exit For
                End If
             End If
        Next
     
        ' ...and here is my table looked for
        MsgBox MyPara.Next.Range.Tables(1).Cell(1, 1).Range

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 2
    Dernier message: 18/11/2012, 11h25
  2. Réponses: 3
    Dernier message: 24/11/2010, 16h52
  3. [WD-2003] Trouver le premier tableau à partir d'un endroit d'un fichier
    Par Yoyo57 dans le forum VBA Word
    Réponses: 12
    Dernier message: 05/08/2010, 21h16
  4. Réponses: 11
    Dernier message: 19/02/2009, 14h49
  5. [XSLT] Créer un tableau à partir de sa description
    Par Skyou dans le forum XSL/XSLT/XPATH
    Réponses: 5
    Dernier message: 20/03/2005, 20h01

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo