mat_dd
Messages postés2Date d'inscriptionmardi 16 août 2016StatutMembreDernière intervention16 août 2016
-
Modifié par NHenry le 16/08/2016 à 12:25
mat_dd
Messages postés2Date d'inscriptionmardi 16 août 2016StatutMembreDernière intervention16 août 2016
-
16 août 2016 à 12:34
Bonjour à tous,
J'ai voulu mettre en place une macro permettant de collecter des données dans Excel puis de les transférer dans Word.
J'ai une maquette sous Word, la macro crée la structure nécessaire, puis elle n'a plus qu'à insérer les données là ou il faut.
Mais je n'arrive pas à utiliser Find Replace sous VBA. Il me renvoit l'erreur d'exécution 438 : Propriété ou méthode non gérée par cet objet.
Je vous laisse regarder.
Merci d'avance pour vos réponses.
"
Sub NoteAct()
'Application.ScreenUpdating = False
Dim ech(480) As Single
Dim ech2(30) As Single
Dim ech3(30) As Single
Dim ech4(30) As Single
Dim stech(480) As String
Dim ech_ass(480) As Single
Dim ech_ass2(40) As Single
Dim ech_ass3(40) As Single
Dim ech_ass4(40) As Single
Dim ech_ass5(480) As Single
Dim ech_ass6(480) As Single
Dim stech_ass(480) As String
Dim stech_ass5(480) As String
Dim stech_ass6(480) As String
Dim assh_f(2, 2) As Single
Dim ass(480) As Single
Dim ass2(40) As Single
Dim ass3(40) As Single
Dim ass4(40) As Single
Dim stass(480) As String
Dim ass_h_f(2, 4) As Single
Dim ech_fam(480) As Single
Dim ech_fam2(40) As Single
Dim ech_fam3(40) As Single
Dim ech_fam4(40) As Single
Dim stech_fam(480) As String
capitall = Range("F2")
Dim capital(4) As String
Dim incidence(8, 4) As String
Dim decimale(2) As Single
Dim ech_ass_echass(40) As String
famm = Range("H4")
famp = Range("I4")
j = 0
If famm > 0 Then
j = famp
End If
For i = 1 To j
ech(i) = Range("D" & 2 + i)
ech_ass(i) = Range("D" & 2 + i) + Range("E" & 2 + i) - famm
ass(i) = Range("E" & 2 + i) - famm
ech_fam(i) = Range("D" & 2 + i) + Range("E" & 2 + i)
Next
For i = j + 1 To 480
ech(i) = Range("D" & 2 + i)
ech_ass(i) = Range("D" & 2 + i) + Range("E" & 2 + i)
ass(i) = Range("E" & 2 + i)
ech_fam(i) = Range("D" & 2 + i) + Range("E" & 2 + i)
Next
For i = 1 To 2
ass_h_f(i, 1) = Range("H" & 23 + i)
ass_h_f(i, 2) = Range("I" & 23 + i)
ass_h_f(i, 3) = Range("O" & 23 + i)
ass_h_f(i, 4) = Range("F" & 2 + i)
Next
h = 1
j = 1
l = 1
m = 1
ech2(1) = h
ech3(1) = h
ech_ass2(1) = j
ech_ass3(1) = j
ech_ass5(1) = ass_h_f(1, 1) * ass_h_f(1, 2) * capitall / 12
ech_ass6(1) = ass_h_f(2, 1) * ass_h_f(2, 2) * capitall / 12
ass2(1) = m
ass3(1) = m
ech_fam2(1) = h
ech_fam3(1) = h
cpt = 0
For i = 1 To 479
cpt = cpt + 1
If ech(i + 1) <> ech(i) Then
h = h + 1
ech(h) = ech(i + 1)
ech4(h - 1) = cpt
ech3(h) = cpt + 1
ech2(h - 1) = ech4(h - 1) - ech3(h - 1) + 1
End If
If ass(i + 1) <> ass(i) Then
m = m + 1
ass(m) = ass(i + 1)
ass4(m - 1) = cpt
ass3(m) = cpt + 1
ass2(m - 1) = ass4(m - 1) - ass3(m - 1) + 1
End If
If ech_ass(i + 1) <> ech_ass(i) Then
j = j + 1
ech_ass(j) = ech_ass(i + 1)
ech_ass4(j - 1) = cpt
ech_ass3(j) = cpt + 1
ech_ass2(j - 1) = ech_ass4(j - 1) - ech_ass3(j - 1) + 1
If ass_h_f(1, 3) >= ech_ass4(j - 1) Then
ech_ass5(j - 1) = ass_h_f(1, 1) * ass_h_f(1, 2) * capitall / 12
Else: ech_ass5(j - 1) = 0
End If
If ass_h_f(2, 3) >= ech_ass4(j - 1) Then
ech_ass6(j - 1) = ass_h_f(2, 1) * ass_h_f(2, 2) * capitall / 12
Else: ech_ass6(j - 1) = 0
End If
End If
If ech_fam(i + 1) <> ech_fam(i) Then
l = l + 1
ech_fam(l) = ech_fam(i + 1)
ech_fam4(l - 1) = cpt
ech_fam3(l) = cpt + 1
ech_fam2(l - 1) = ech_fam4(l - 1) - ech_fam3(l - 1) + 1
End If
Next
For i = j + 1 To 480
ech_ass(i) = 0
Next
For i = m + 1 To 480
ass(i) = 0
Next
For i = h + 1 To 480
ech(i) = 0
Next
For i = l + 1 To 480
ech_fam(i) = 0
Next
'For i = 1 To 480
' If ech_ass(i) > 0 Then
' Range("F" & 28 + i) = ech_ass(i)
' Range("G" & 28 + i) = ech_ass2(i)
' Range("H" & 28 + i) = ech_ass3(i)
' Range("I" & 28 + i) = ech_ass4(i)
' Range("J" & 28 + i) = ech_ass5(i)
' Range("J" & 28 + i) = ech_ass6(i)
' End If
'Next
Dim stdossier As String
dossier = Range("i1")
If dossier >= 1000 Then
stdossier = Format(dossier, "#"".""##0.00")
Else: stdossier = Format(dossier, "##0.00")
End If
Dim stgarantie As String
garantie = Range("l1")
If garantie >= 1000 Then
stgarantie = Format(garantie, "###"".""##0.00")
Else: stgarantie = Format(garantie, "##0.00")
End If
Dim stcourtage As String
courtage = Range("m1")
If courtage >= 1000 Then
stcourtage = Format(courtage, "###"".""##0.00")
Else: stcourtage = Format(courtage, "##0.00")
End If
Dim stcontrole As String
controle = Range("n1")
If controle >= 1000 Then
stcontrole = Format(controle, "###"".""##0.00")
Else: stcontrole = Format(controle, "##0.00")
End If
Dim duree As String
nb_ech = 1
While ech(nb_ech) <> 0
nb_ech = nb_ech + 1
Range("f29") = nb_ech
Wend
nb_ech_ass = 1
While ech_ass(nb_ech_ass) <> 0
nb_ech_ass = nb_ech_ass + 1
Range("f30") = nb_ech_ass
Wend
nb_ech_fam = 1
While ech_fam(nb_ech_fam) <> 0
nb_ech_fam = nb_ech_fam + 1
Range("f31") = nb_ech_fam
Wend
If ech4(nb_ech - 1) Mod 12 = 0 Then
duree = ech4(nb_ech - 1) & " ans"
Else: duree = ech4(nb_ech - 1) & " ans et " & ech4(nb_ech - 1) Mod 12 & " mois"
End If
For i = 1 To 4
If Range("J" & 4 + i) >= 1000000 Then
capital(i) = Format(Range("J" & 4 + i), "###"".""###"".""##0.00")
Else: capital(i) = Format(Range("J" & 4 + i), "###"".""##0.00")
End If
Next
For i = 1 To 8
For j = 1 To 2
incidence(i, j) = Format(Cells(12 + i, 10 + j) * 100, "0.000")
Next
For j = 3 To 4
incidence(i, j) = Format(Cells(12 + i, 10 + j) * 100, "0.00")
Next
Next
For i = 1 To 2
decimale(i) = Range("N" & 7 + i)
Next
For i = 1 To 2
For j = 1 To 2
assh_f(i, j) = Cells(23 + i, 7 + j)
Next
Next
For i = 1 To 480
If ech(i) >= 1000 Then
stech(i) = Format(ech(i), "#"".""##0.00")
Else: stech(i) = Format(ech(i), "##0.00")
End If
Range("F" & 27 + i) = stech(i)
If ech_ass(i) >= 1000 Then
stech_ass(i) = Format(ech_ass(i), "#"".""##0.00")
Else: stech_ass(i) = Format(ech_ass(i), "##0.00")
End If
Range("G" & 27 + i) = stech_ass(i)
If ech_ass5(i) >= 1000 Then
stech_ass5(i) = Format(ech_ass5(i), "#"".""##0.00")
Else: stech_ass5(i) = Format(ech_ass5(i), "##0.00")
End If
Range("F" & 27 + i) = ech_ass5(i)
If ech_ass6(i) >= 1000 Then
stech_ass6(i) = Format(ech_ass6(i), "#"".""##0.00")
Else: stech_ass6(i) = Format(ech_ass6(i), "##0.00")
End If
Range("G" & 27 + i) = ech_ass6(i)
If ass(i) >= 1000 Then
stass(i) = Format(ass(i), "#"".""##0.00")
Else: stass(i) = Format(ass(i), "##0.00")
End If
Range("H" & 27 + i) = stass(i)
If ech_fam(i) >= 1000 Then
stech_fam(i) = Format(ech_fam(i), "#"".""##0.00")
Else: stech_fam(i) = Format(ech_fam(i), "##0.00")
End If
Range("I" & 27 + i) = stech_fam(i)
Next
feuille_actuelle = ActiveSheet.Name
Dim Note As Object
Set Note = New Word.Application
'Set Note = Nothing
Note.WindowState = wdWindowStateMaximize
Note.Visible = True
'Note.Application.ScreenUpdating = False
Note.Documents.Open Filename:="Q:\Documents\modele_initial3.docx"
'Note.ActiveDocument.SaveAs Filename:="Q:\Documents\dossier_teg\" & feuille_actuelle & ".doc"
nbelement = 1
nbb = 2
Dim taux As Single
taux = Range("F6")
If famm = 0 Then
Note.Selection.MoveUp Unit:=wdLine, Count:=600
Note.Selection.Find.Text = "Assistance Famille Plus"
Note.Selection.Find.Forward = True
Note.Selection.Find.Execute
Note.Selection.MoveLeft Unit:=wdCharacter, Count:=1
Note.Selection.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend
Note.Selection.TypeBackspace
Note.Selection.Find.Text = "La cotisation mensuelle d'Assistance Famille Plus s'élève à"
Note.Selection.Find.Forward = True
Note.Selection.Find.Execute
Note.Selection.MoveLeft Unit:=wdCharacter, Count:=1
Note.Selection.MoveUp Unit:=wdLine, Count:=3
Note.Selection.MoveDown Unit:=wdLine, Count:=40, Extend:=wdExtend
Note.Selection.TypeBackspace
Note.Selection.Find.Text = "Assistance Famille Plus"
Note.Selection.Find.Forward = True
Note.Selection.Find.Execute
Note.Selection.MoveLeft Unit:=wdCharacter, Count:=1
Note.Selection.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend
Note.Selection.TypeBackspace
End If
If ass_h_f(1, 1) = 0 And ass_h_f(2, 1) = 0 Then
Note.Selection.MoveUp Unit:=wdLine, Count:=600
Note.Selection.Find.Text = "Assurance Décès Invalidité - Perte totale et Irréversible d'Autonomie"
Note.Selection.Find.Forward = True
Note.Selection.Find.Execute
Note.Selection.MoveLeft Unit:=wdCharacter, Count:=1
Note.Selection.MoveDown Unit:=wdLine, Count:=7, Extend:=wdExtend
Note.Selection.TypeBackspace
Note.Selection.Find.Text = "Le montant des cotisations d'assurance DI-PTIA s'élève à"
Note.Selection.Find.Forward = True
Note.Selection.Find.Execute
Note.Selection.MoveLeft Unit:=wdCharacter, Count:=1
Note.Selection.MoveUp Unit:=wdLine, Count:=2
Note.Selection.MoveDown Unit:=wdLine, Count:=37, Extend:=wdExtend
Note.Selection.TypeBackspace
Note.Selection.Find.Text = "Assurance Emprunteur"
Note.Selection.Find.Forward = True
Note.Selection.Find.Execute
Note.Selection.MoveLeft Unit:=wdCharacter, Count:=1
Note.Selection.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend
Note.Selection.TypeBackspace
End If
If controle = 0 Then
Note.Selection.MoveUp Unit:=wdLine, Count:=600
Note.Selection.Find.Text = "Frais de contrôle d'avancement de travaux"
Note.Selection.Find.Forward = True
Note.Selection.Find.Execute
Note.Selection.MoveLeft Unit:=wdCharacter, Count:=1
Note.Selection.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend
Note.Selection.TypeBackspace
Note.Selection.Find.Text = "Les frais de contrôle d'avancement de travaux sont égaux"
Note.Selection.Find.Forward = True
Note.Selection.Find.Execute
Note.Selection.MoveLeft Unit:=wdCharacter, Count:=1
Note.Selection.MoveUp Unit:=wdLine, Count:=2
Note.Selection.MoveDown Unit:=wdLine, Count:=30, Extend:=wdExtend
Note.Selection.TypeBackspace
Note.Selection.Find.Text = "Frais de contrôle d'avancement"
Note.Selection.Find.Forward = True
Note.Selection.Find.Execute
Note.Selection.MoveLeft Unit:=wdCharacter, Count:=1
Note.Selection.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend
Note.Selection.TypeBackspace
Else: nbelement = nbelement + 1
End If
If courtage = 0 Then
Note.Selection.MoveUp Unit:=wdLine, Count:=600
Note.Selection.Find.Text = "Frais de courtage"
Note.Selection.Find.Forward = True
Note.Selection.Find.Execute
Note.Selection.MoveLeft Unit:=wdCharacter, Count:=1
Note.Selection.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend
Note.Selection.TypeBackspace
Note.Selection.Find.Text = "Les frais de courtage sont égaux"
Note.Selection.Find.Forward = True
Note.Selection.Find.Execute
Note.Selection.MoveLeft Unit:=wdCharacter, Count:=1
Note.Selection.MoveUp Unit:=wdLine, Count:=2
Note.Selection.MoveDown Unit:=wdLine, Count:=29, Extend:=wdExtend
Note.Selection.TypeBackspace
Note.Selection.Find.Text = "Frais de courtage"
Note.Selection.Find.Forward = True
Note.Selection.Find.Execute
Note.Selection.MoveLeft Unit:=wdCharacter, Count:=1
Note.Selection.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend
Note.Selection.TypeBackspace
Else: nbelement = nbelement + 1
End If
If garantie = 0 Then
Note.Selection.MoveUp Unit:=wdLine, Count:=600
Note.Selection.Find.Text = "Frais de garantie hypothécaire"
Note.Selection.Find.Forward = True
Note.Selection.Find.Execute
Note.Selection.MoveLeft Unit:=wdCharacter, Count:=1
Note.Selection.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend
Note.Selection.TypeBackspace
Note.Selection.Find.Text = "Les frais de garantie hypothécaire sont égaux"
Note.Selection.Find.Forward = True
Note.Selection.Find.Execute
Note.Selection.MoveLeft Unit:=wdCharacter, Count:=1
Note.Selection.MoveUp Unit:=wdLine, Count:=1
Note.Selection.MoveDown Unit:=wdLine, Count:=27, Extend:=wdExtend
Note.Selection.TypeBackspace
Note.Selection.Find.Text = "Frais de garantie "
Note.Selection.Find.Forward = True
Note.Selection.Find.Execute
Note.Selection.MoveLeft Unit:=wdCharacter, Count:=1
Note.Selection.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend
Note.Selection.TypeBackspace
Else: nbelement = nbelement + 1
End If
If dossier = 0 Then
Note.Selection.MoveUp Unit:=wdLine, Count:=600
Note.Selection.Find.Text = "Frais de dossier"
Note.Selection.Find.Forward = True
Note.Selection.Find.Execute
Note.Selection.MoveLeft Unit:=wdCharacter, Count:=1
Note.Selection.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend
Note.Selection.TypeBackspace
Note.Selection.Find.Text = "Les frais de dossier sont égaux"
Note.Selection.Find.Forward = True
Note.Selection.Find.Execute
Note.Selection.MoveLeft Unit:=wdCharacter, Count:=1
Note.Selection.MoveUp Unit:=wdLine, Count:=1
Note.Selection.MoveDown Unit:=wdLine, Count:=26, Extend:=wdExtend
Note.Selection.TypeBackspace
Note.Selection.Find.Text = "Frais de dossier"
Note.Selection.Find.Forward = True
Note.Selection.Find.Execute
Note.Selection.MoveLeft Unit:=wdCharacter, Count:=1
Note.Selection.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend
Note.Selection.TypeBackspace
Note.Selection.Find
Note.Selection.Find.Text = " de dossier"
Note.Selection.Find.Replacement.Text = ""
Note.Selection.Find.Forward = True
Note.Selection.Find.MatchCase = True
Note.Selection.Find.MatchWholeWord = True
Note.Selection.Find.Execute Replace:=wdReplaceAll
Note.Selection.MoveUp Unit:=wdLine, Count:=600
Note.Selection.Find
Note.Selection.Find.Text = "fraisdossier+"
Note.Selection.Find.Replacement.Text = ""
Note.Selection.Find.Forward = True
Note.Selection.Find.MatchCase = True
Note.Selection.Find.MatchWholeWord = True
Note.Selection.Find.Execute Replace:=wdReplaceAll
Else:
nbelement = nbelement + 1
nbb = nbb + 1
Note.Selection.MoveUp Unit:=wdLine, Count:=600
Note.Selection.Find.Text = "XXXX"
Note.Selection.Find.Replacement.Text = nbb
Note.Selection.Find.Forward = True
Note.Selection.Find.MatchCase = True
Note.Selection.Find.MatchWholeWord = True
Note.Selection.Find.Execute Replace:=wdReplaceOne
End If
Note.Selection.MoveUp Unit:=wdLine, Count:=1
If garantie = 0 Then
Note.Selection.MoveUp Unit:=wdLine, Count:=600
Note.Selection.Find.Text = ", de garantie hypothécaire"
Note.Selection.Find.Replacement.Text = ""
Note.Selection.Find.Forward = True
Note.Selection.Find.MatchCase = True
Note.Selection.Find.MatchWholeWord = True
Note.Selection.Find.Execute Replace:=wdReplaceAll
Note.Selection.MoveUp Unit:=wdLine, Count:=600
Note.Selection.Find.Text = "fraisgarantie+"
Note.Selection.Find.Replacement.Text = ""
Note.Selection.Find.Forward = True
Note.Selection.Find.MatchCase = True
Note.Selection.Find.MatchWholeWord = True
Note.Selection.Find.Execute Replace:=wdReplaceAll
Else:
nbb = nbb + 1
Note.Selection.Find.Text = "XXXX"
Note.Selection.Find.Replacement.Text = nbb
Note.Selection.Find.Forward = True
Note.Selection.Find.MatchCase = True
Note.Selection.Find.MatchWholeWord = True
Note.Selection.Find.Execute Replace:=wdReplaceOne
End If
Note.Selection.MoveUp Unit:=wdLine, Count:=1
If courtage = 0 Then
Note.Selection.MoveUp Unit:=wdLine, Count:=600
With Note.Selection.Find
.Text = ", de courtage"
.Replacement.Text = ""
.Forward = True
.MatchCase = True
.MatchWholeWord = True
End With
Note.Selection.Find.Execute Replace:=wdReplaceAll
Note.Selection.MoveUp Unit:=wdLine, Count:=600
With Note.Selection.Find
.Text = "fraiscourtage+"
.Replacement.Text = ""
.Forward = True
.MatchCase = True
.MatchWholeWord = True
End With
Note.Selection.Find.Execute Replace:=wdReplaceAll
Else
nbb = nbb + 1
Note.Selection.Find.Text = "XXXX"
Note.Selection.Find.Replacement.Text = nbb
Note.Selection.Find.Forward = True
Note.Selection.Find.MatchCase = True
Note.Selection.Find.MatchWholeWord = True
Note.Selection.Find.Execute Replace:=wdReplaceOne
End If
Note.Selection.MoveUp Unit:=wdLine, Count:=1
If controle = 0 Then
Note.Selection.MoveUp Unit:=wdLine, Count:=600
With Note.Selection.Find
.Text = ", de contrôle d'avancement de travaux"
.Replacement.Text = ""
.Forward = True
.MatchCase = True
.MatchWholeWord = True
End With
Note.Selection.Find.Execute Replace:=wdReplaceAll
Note.Selection.MoveUp Unit:=wdLine, Count:=600
With Note.Selection.Find
.Text = "fraiscontrole+"
.Replacement.Text = ""
.Forward = True
.MatchCase = True
.MatchWholeWord = True
End With
Note.Selection.Find.Execute Replace:=wdReplaceAll
Else
nbb = nbb + 1
Note.Selection.Find.Text = "XXXX"
Note.Selection.Find.Replacement.Text = nbb
Note.Selection.Find.Forward = True
Note.Selection.Find.MatchCase = True
Note.Selection.Find.MatchWholeWord = True
Note.Selection.Find.Execute Replace:=wdReplaceOne
End If
Note.Selection.MoveUp Unit:=wdLine, Count:=1
If ass_h_f(1, 1) > 0 Or ass_h_f(2, 1) > 0 Then
nbb = nbb + 1
Note.Selection.Find.Text = "XXXX"
Note.Selection.Find.Replacement.Text = nbb
Note.Selection.Find.Forward = True
Note.Selection.Find.MatchCase = True
Note.Selection.Find.MatchWholeWord = True
Note.Selection.Find.Execute Replace:=wdReplaceOne
Note.Selection.MoveRight Unit:=wdCharacter, Count:=1
End If
If famm > 0 Then
nbb = nbb + 1
Note.Selection.Find.Text = "XXXX"
Note.Selection.Find.Replacement.Text = nbb
Note.Selection.Find.Forward = True
Note.Selection.Find.MatchCase = True
Note.Selection.Find.MatchWholeWord = True
Note.Selection.Find.Execute Replace:=wdReplaceOne
End If
Note.Selection.MoveUp Unit:=wdLine, Count:=600
With Note.Selection.Find
.Text = "des frais,"
.Replacement.Text = "des frais"
.Forward = True
.MatchCase = True
.MatchWholeWord = True
End With
Note.Selection.Find.Execute Replace:=wdReplaceAll
Note.Selection.MoveUp Unit:=wdLine, Count:=600
With Note.Selection.Find
.Text = "des frais et"
.Replacement.Text = "des frais"
.Forward = True
.MatchCase = True
.MatchWholeWord = True
End With
Note.Selection.Find.Execute Replace:=wdReplaceAll
i = 0
If (nb_ech - 1) Mod 2 = 0 Then
i = 1
End If
j = 0
If (nb_ech_ass - 1) Mod 2 = 0 Then
j = 1
End If
k = 0
If (nb_ech_fam - 1) Mod 2 = 0 Then
k = 1
End If
Note.Selection.MoveUp Unit:=wdLine, Count:=600
With Note.Selection.Find
.Text = "ech" & nb_ech
.Forward = True
.MatchCase = True
.MatchWholeWord = True
End With
Note.Selection.Find.Execute
For j = 1 To nbelement
Note.Selection.Find.Execute
Note.Selection.MoveLeft Unit:=wdCharacter, Count:=3
Note.Selection.MoveRight Unit:=wdCharacter, Count:=i * 7, Extend:=wdExtend
Note.Selection.MoveRight Unit:=wdCharacter, Count:=(30 - nb_ech) / 2 * 13, Extend:=wdExtend
Note.Selection.MoveRight Unit:=wdCharacter, Count:=(1 - i) * 7 - 1, Extend:=wdExtend
Note.Selection.TypeBackspace
Next
If ass_h_f(1, 1) > 0 Or ass_h_f(1, 1) > 0 Then
With Note.Selection.Find
.Text = "echadi" & nb_ech_ass
.Forward = True
.MatchCase = True
.MatchWholeWord = True
End With
Note.Selection.Find.Execute
Note.Selection.MoveRight Unit:=wdCharacter, Count:=9
Note.Selection.MoveDown Unit:=wdLine, Count:=30 - nb_ech_ass + 1, Extend:=wdExtend
Note.Selection.MoveLeft Unit:=wdCharacter, Count:=3, Extend:=wdExtend
Note.Selection.Cells.Delete ShiftCells:=wdDeleteCellsShiftLeft
Note.Selection.Find.Execute
Note.Selection.MoveLeft Unit:=wdCharacter, Count:=3
Note.Selection.MoveRight Unit:=wdCharacter, Count:=j * 7, Extend:=wdExtend
Note.Selection.MoveRight Unit:=wdCharacter, Count:=(30 - nb_ech_ass) / 2 * 13, Extend:=wdExtend
Note.Selection.MoveRight Unit:=wdCharacter, Count:=(1 - j) * 7 - (1 - j), Extend:=wdExtend
Note.Selection.TypeBackspace
End If
If famm > 0 Then
With Note.Selection.Find
.Text = "echfamplus" & nb_ech_fam
.Forward = True
.MatchCase = True
.MatchWholeWord = True
End With
Note.Selection.Find.Execute
Note.Selection.MoveLeft Unit:=wdCharacter, Count:=3
Note.Selection.MoveRight Unit:=wdCharacter, Count:=k * 7, Extend:=wdExtend
Note.Selection.MoveRight Unit:=wdCharacter, Count:=(30 - nb_ech_fam) / 2 * 13, Extend:=wdExtend
Note.Selection.MoveRight Unit:=wdCharacter, Count:=(k - i) * 7 - 1, Extend:=wdExtend
Note.Selection.TypeBackspace
End If
Note.Selection.MoveUp Unit:=wdLine, Count:=600
With Note.Selection.Find
.Text = "ech" & nb_ech
.Forward = True
.MatchCase = True
.MatchWholeWord = True
End With
Note.Selection.Find.Execute
Note.Selection.MoveLeft Unit:=wdCharacter, Count:=3
Note.Selection.MoveDown Unit:=wdLine, Count:=30 - nb_ech + 1, Extend:=wdExtend
Note.Selection.TypeBackspace
If ass_h_f(1, 1) > 0 Or ass_h_f(2, 1) > 0 Then
If ech(1) > 0 Then
For i = 1 To 2
Note.Selection.MoveUp Unit:=wdLine, Count:=600
With Note.Selection.Find
.Text = "montantpret2"
.Forward = True
.MatchCase = True
.MatchWholeWord = True
End With
Note.Selection.Find.Execute
Note.Selection.MoveLeft Unit:=wdCharacter, Count:=4
Note.Selection.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend
Note.Selection.TypeBackspace
Next
End If
If ass_h_f(1, 1) = 0 Then
Note.Selection.MoveUp Unit:=wdLine, Count:=600
With Note.Selection.Find
.Text = "Monsieur : taux de cotisation"
.Forward = True
.MatchCase = True
.MatchWholeWord = True
End With
Note.Selection.Find.Execute
Note.Selection.MoveLeft Unit:=wdCharacter, Count:=3
Note.Selection.MoveDown Unit:=wdLine, Count:=3
Note.Selection.TypeBackspace
With Note.Selection.Find
.Text = "Pour Monsieur :"
.Forward = True
.MatchCase = True
.MatchWholeWord = True
End With
Note.Selection.Find.Execute
Note.Selection.MoveLeft Unit:=wdCharacter, Count:=1
Note.Selection.MoveDown Unit:=wdLine, Count:=3
Note.Selection.TypeBackspace
Else
Note.Selection.MoveUp Unit:=wdLine, Count:=600
With Note.Selection.Find
.Text = "Madame : taux de cotisation"
.Forward = True
.MatchCase = True
.MatchWholeWord = True
End With
Note.Selection.Find.Execute
Note.Selection.MoveLeft Unit:=wdCharacter, Count:=3
Note.Selection.MoveDown Unit:=wdLine, Count:=3, Extend:=wdExtend
Note.Selection.TypeBackspace
With Note.Selection.Find
.Text = "Pour Madame :"
.Forward = True
.MatchCase = True
.MatchWholeWord = True
End With
Note.Selection.Find.Execute
Note.Selection.MoveLeft Unit:=wdCharacter, Count:=1
Note.Selection.MoveDown Unit:=wdLine, Count:=3, Extend:=wdExtend
Note.Selection.TypeBackspace
End If
Note.Selection.MoveUp Unit:=wdLine, Count:=600
End If
Note.Content.Find.Execute Findtext:="montantpret", replacewith:=capital(1), Replace:=wdReplaceAll
' .Text = "montantpret"
' .Replacemement.Text = capital(1)
' .Forward = True
' End With
'Note.Selection.Find.Execute Replace:=wdReplaceAll
Note.Selection.MoveUp Unit:=wdLine, Count:=600
With Note.Selection.Find
.Text = "tauxpret"
.Replacemement.Text = taux
.Forward = True
.MatchCase = True
.MatchWholeWord = True
End With
Note.Selection.Find.Execute Replace:=wdReplaceAll
Note.Selection.MoveUp Unit:=wdLine, Count:=600
With Note.Selection.Find
.Text = "annee"
.Replacemement.Text = duree
.Forward = True
.MatchCase = True
.MatchWholeWord = True
End With
Note.Selection.Find.Execute Replace:=wdReplaceAll
Note.Selection.MoveUp Unit:=wdLine, Count:=600
With Note.Selection.Find
.Text = "nbech"
.Replacemement.Text = ech4(nb_ech - 1)
.Forward = True
.MatchCase = True
.MatchWholeWord = True
End With
Note.Selection.Find.Execute Replace:=wdReplaceAll
Note.Selection.MoveUp Unit:=wdLine, Count:=600
With Note.Selection.Find
.Text = "fraisdossier"
.Replacemement.Text = stdossier
.Forward = True
.MatchCase = True
.MatchWholeWord = True
End With
Note.Selection.Find.Execute Replace:=wdReplaceAll
Note.Selection.MoveUp Unit:=wdLine, Count:=600
With Note.Selection.Find
.Text = "fraisgarantie"
.Replacemement.Text = stgarantie
.Forward = True
.MatchCase = True
.MatchWholeWord = True
End With
Note.Selection.Find.Execute Replace:=wdReplaceAll
Note.Selection.MoveUp Unit:=wdLine, Count:=600
With Note.Selection.Find
.Text = "fraiscourtage"
.Replacemement.Text = stcourtage
.Forward = True
.MatchCase = True
.MatchWholeWord = True
End With
Note.Selection.Find.Execute Replace:=wdReplaceAll
Note.Selection.MoveUp Unit:=wdLine, Count:=600
With Note.Selection.Find
.Text = "fraiscontrole"
.Replacemement.Text = stcontrole
.Forward = True
.MatchCase = True
.MatchWholeWord = True
End With
Note.Selection.Find.Execute Replace:=wdReplaceAll
Note.Selection.MoveUp Unit:=wdLine, Count:=600
With Note.Selection.Find
.Text = "primeadih"
.Replacemement.Text = Format(ass_h_f(1, 2) * 100, "0.000")
.Forward = True
.MatchCase = True
.MatchWholeWord = True
End With
Note.Selection.Find.Execute Replace:=wdReplaceAll
Note.Selection.MoveUp Unit:=wdLine, Count:=600
With Note.Selection.Find
.Text = "primeadif"
.Replacemement.Text = Format(ass_h_f(2, 2) * 100, "0.000")
.Forward = True
.MatchCase = True
.MatchWholeWord = True
End With
Note.Selection.Find.Execute Replace:=wdReplaceAll
Note.Selection.MoveUp Unit:=wdLine, Count:=600
With Note.Selection.Find
.Text = "adih"
.Replacemement.Text = Format(ass_h_f(1, 1) * 100, "0.000")
.Forward = True
.MatchCase = True
.MatchWholeWord = True
End With
Note.Selection.Find.Execute Replace:=wdReplaceAll
Note.Selection.MoveUp Unit:=wdLine, Count:=600
With Note.Selection.Find
.Text = "adif"
.Replacemement.Text = Format(ass_h_f(2, 1) * 100, "0.000")
.Forward = True
.MatchCase = True
.MatchWholeWord = True
End With
Note.Selection.Find.Execute Replace:=wdReplaceAll
Note.Selection.MoveUp Unit:=wdLine, Count:=600
For i = 1 To nb_ech - 1
With Note.Selection.Find
.Text = "ech" & i
.Replacemement.Text = stech(i)
.Forward = True
.MatchCase = True
.MatchWholeWord = True
End With
Note.Selection.Find.Execute Replace:=wdReplaceAll
Note.Selection.MoveUp Unit:=wdLine, Count:=600
Next
Note.Application.ScreenUpdating = True
Application.ScreenUpdating = True
End Sub
"
EDIT : Ajout des balises de code (la coloration syntaxique). Explications disponibles ici : ICI