Word macro Excel

Bonjour

je voudrais cree une macro word qui copie des donner d'un tableau word vers un tableaux excel dans des cellule precisse mais je bloque ...

Bonjour,

Cela aurait pu être ce code :

Sub MettreAJourDesCellulesDansExcel()

Dim DocEnCours As Document
Dim Chemin As String
Dim TableDoc As Table
Dim XlApp As Excel.Application   ' Référencer Microsoft Excel
Dim FichierExcel As Excel.Workbook

    Set DocEnCours = ActiveDocument
    With DocEnCours
         Set TableDoc = .Tables(1)
         Chemin = .Path & "\" & "Classeur1.xlsx" ' ContenuCellule adapter
    End With

    Set XlApp = CreateObject("Excel.Application")
    With XlApp
         .Visible = True
          Set FichierExcel = .Workbooks.Open(FileName:=Chemin)
          With FichierExcel
               With .Sheets(1)
                    .Range("B40") = CelluleWord(TableDoc, 1, 2)
                    .Range("C40") = CelluleWord(TableDoc, 1, 3)
                    .Range("A44") = CelluleWord(TableDoc, 4, 1)
               End With
               '.Close savechanges:=True
         End With
     End With

     ' XlApp.Quit

      Set XlApp = Nothing: Set FichierExcel = Nothing
      Set DocEnCours = Nothing: Set TableDoc = Nothing

End Sub

Function CelluleWord(ByVal TableDoc As Table, ByVal Ligne As Integer, ByVal Colonne As Integer) As Variant

Dim ContenuCellule As Variant

        CelluleWord = ""
        ContenuCellule = TableDoc.Cell(Ligne, Colonne).Range.Text
        CelluleWord = Mid(ContenuCellule, 1, Len(ContenuCellule) - 1)

End Function
Rechercher des sujets similaires à "word macro"