OVH Cloud OVH Cloud

Accélérer le formattage d'un tableau avec bordures

1 réponse
Avatar
Alex St-Pierre
Bonjour!
Après la copie d'un tableau excel dans Word, j'ai un programme qui
transforme le format Word en fonction de celui d'Excel. Lorsque je transforme
les bordures, le programme est vraiment très lent. Y-a-t-il un moyen
d'accéler le tout?

Les lignes simple en excel prenne la valeur 4 (0.5 point) en Word par
défaut, je les mets à (0.25pt) et les lignes en gras prennent la valeur 8 (1
pt) par défaut, je les mets à (1.50pt).
Merci !
Alex
Set oXlRng = AppExcel.Range("Tableau")
Set tbl = AppWord.Tables(1)
With tbl
For i = 1 To tbl.Rows.Count
For j = 1 To 5
With oXlRng.Cells(i, j)
With .Borders(xlEdgeTop)
If .LineStyle = xlContinuous Then
tbl.Cell(i, j).Borders(wdBorderTop).LineStyle =
wdLineStyleSingle
If .Weight = xlThin Then
tbl.Cell(i, j).Borders(wdBorderTop).LineWidth =
wdLineWidth025pt
ElseIf .Weight = xlMedium Then 'Or .Weight = xlLarge Then
tbl.Cell(i, j).Borders(wdBorderTop).LineWidth =
wdLineWidth150pt
End If
Else
tbl.Cell(i, j).Borders(wdBorderTop).LineStyle =
wdLineStyleNone
End If
End With
With .Borders(xlEdgeBottom)
If .LineStyle = xlContinuous Then
tbl.Cell(i, j).Borders(wdBorderBottom).LineStyle =
wdLineStyleSingle
If .Weight = xlThin Then
tbl.Cell(i, j).Borders(wdBorderBottom).LineWidth =
wdLineWidth025pt
ElseIf .Weight = xlMedium Then
tbl.Cell(i, j).Borders(wdBorderBottom).LineWidth =
wdLineWidth150pt
End If
Else
tbl.Cell(i, j).Borders(wdBorderBottom).LineStyle =
wdLineStyleNone
End If
End With
With .Borders(xlEdgeLeft)
If .LineStyle = xlContinuous Then
tbl.Cell(i, j).Borders(wdBorderLeft).LineStyle =
wdLineStyleSingle
If .Weight = xlThin Then
tbl.Cell(i, j).Borders(wdBorderLeft).LineWidth =
wdLineWidth025pt
ElseIf .Weight = xlMedium Then
tbl.Cell(i, j).Borders(wdBorderLeft).LineWidth =
wdLineWidth150pt
End If
Else
tbl.Cell(i, j).Borders(wdBorderLeft).LineStyle =
wdLineStyleNone
End If
End With
With .Borders(xlEdgeRight)
If .LineStyle = xlContinuous Then
tbl.Cell(i, j).Borders(wdBorderRight).LineStyle =
wdLineStyleSingle
If .Weight = xlThin Then
tbl.Cell(i, j).Borders(wdBorderRight).LineWidth =
wdLineWidth025pt
ElseIf .Weight = xlMedium Then
tbl.Cell(i, j).Borders(wdBorderRight).LineWidth =
wdLineWidth150pt
End If
Else
tbl.Cell(i, j).Borders(wdBorderRight).LineStyle =
wdLineStyleNone
End If
End With
End With
--
Alex St-Pierre

1 réponse

Avatar
AB
Bonjour Alex,

Je ne sais pas si tu es obligé d'utiliser cette procédure. Si tel n'est pas
le cas, as-tu envisagé un collage spécial avec liaison : ce dernier
conserve, dans Word, les attributs que tu as définis dans Excel.
Tu peux également appliquer à ton tableau Word un autre style qui te
convient mieux.
Je ne sais pas si ça peut résoudre ton problème...
AB

"Alex St-Pierre" a écrit dans le
message de news:
Bonjour!
Après la copie d'un tableau excel dans Word, j'ai un programme qui
transforme le format Word en fonction de celui d'Excel. Lorsque je
transforme
les bordures, le programme est vraiment très lent. Y-a-t-il un moyen
d'accéler le tout?

Les lignes simple en excel prenne la valeur 4 (0.5 point) en Word par
défaut, je les mets à (0.25pt) et les lignes en gras prennent la valeur 8
(1
pt) par défaut, je les mets à (1.50pt).
Merci !
Alex
Set oXlRng = AppExcel.Range("Tableau")
Set tbl = AppWord.Tables(1)
With tbl
For i = 1 To tbl.Rows.Count
For j = 1 To 5
With oXlRng.Cells(i, j)
With .Borders(xlEdgeTop)
If .LineStyle = xlContinuous Then
tbl.Cell(i, j).Borders(wdBorderTop).LineStyle > wdLineStyleSingle
If .Weight = xlThin Then
tbl.Cell(i, j).Borders(wdBorderTop).LineWidth > wdLineWidth025pt
ElseIf .Weight = xlMedium Then 'Or .Weight = xlLarge
Then
tbl.Cell(i, j).Borders(wdBorderTop).LineWidth > wdLineWidth150pt
End If
Else
tbl.Cell(i, j).Borders(wdBorderTop).LineStyle > wdLineStyleNone
End If
End With
With .Borders(xlEdgeBottom)
If .LineStyle = xlContinuous Then
tbl.Cell(i, j).Borders(wdBorderBottom).LineStyle > wdLineStyleSingle
If .Weight = xlThin Then
tbl.Cell(i, j).Borders(wdBorderBottom).LineWidth > wdLineWidth025pt
ElseIf .Weight = xlMedium Then
tbl.Cell(i, j).Borders(wdBorderBottom).LineWidth > wdLineWidth150pt
End If
Else
tbl.Cell(i, j).Borders(wdBorderBottom).LineStyle > wdLineStyleNone
End If
End With
With .Borders(xlEdgeLeft)
If .LineStyle = xlContinuous Then
tbl.Cell(i, j).Borders(wdBorderLeft).LineStyle > wdLineStyleSingle
If .Weight = xlThin Then
tbl.Cell(i, j).Borders(wdBorderLeft).LineWidth > wdLineWidth025pt
ElseIf .Weight = xlMedium Then
tbl.Cell(i, j).Borders(wdBorderLeft).LineWidth > wdLineWidth150pt
End If
Else
tbl.Cell(i, j).Borders(wdBorderLeft).LineStyle > wdLineStyleNone
End If
End With
With .Borders(xlEdgeRight)
If .LineStyle = xlContinuous Then
tbl.Cell(i, j).Borders(wdBorderRight).LineStyle > wdLineStyleSingle
If .Weight = xlThin Then
tbl.Cell(i, j).Borders(wdBorderRight).LineWidth > wdLineWidth025pt
ElseIf .Weight = xlMedium Then
tbl.Cell(i, j).Borders(wdBorderRight).LineWidth > wdLineWidth150pt
End If
Else
tbl.Cell(i, j).Borders(wdBorderRight).LineStyle > wdLineStyleNone
End If
End With
End With
--
Alex St-Pierre