Bonjour,
j'ai une macro qui fonctionne très bien sur un pc. J'ai voulu la faire fonctionner sur un autre PC et j'ai donc copie-collé le code dans un nouveau fichier. Les signets sont corrects, les chemins d'accès également.
Cependant j'ai le message "Sub ou Function non définie" qui apparait sur la ligne Worskeets(feuille).Activate
Je ne comprends pas pourquoi et comment résoudre ce problème
Merci de votre aide!

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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
Sub Affichage()
'
' Affichage Macro
'
Dim i As Integer
Dim TotPoint As Integer
TotPoint = 0
 
Dim feuille(9) As String
feuille(1) = "AUTONOMIE"
feuille(2) = "MANAGEMENT"
feuille(3) = "RELATIONNEL"
feuille(4) = "IMPACT"
feuille(5) = "AMPLEUR_DES_CONNAISSANCE"
feuille(6) = "COMPLEXITE_ET_SAVOIR_FAIRE_PROF"
feuille(7) = "BONIFICATIONS_RJ"
feuille(8) = "BONIFICATIONS_EI"
 
Dim signetw(9) As String
signetw(1) = "AUTONOMIE"
signetw(2) = "MANAGEMENT"
signetw(3) = "RELATIONNEL"
signetw(4) = "IMPACT"
signetw(5) = "AMPLEUR_DES_CONNAISSANCE"
signetw(6) = "COMPLEXITE_ET_SAVOIR_FAIRE_PROF"
signetw(7) = "BONIFICATIONS_RJ"
signetw(8) = "BONIFICATIONS_EI"
 
 
 
'ouvrir ma feuille excel
Set Ex = CreateObject("Excel.Application")
Ex.Workbooks.Open "C:\Users\Adeline Wattiau\Documents\GERESO SIRH MACROS\Criteres classification v2.xlsx"
 
 
For i = 1 To 8
    TotPoint = TraiteMarche(i, feuille(i), signetw(i), TotPoint)
 
Next i
 
'affichage du total des points
 Call RemplirSignet("TotPoint", CStr(TotPoint))
 
 
End Sub
 
 
Public Function TraiteMarche(i As Integer, feuille As String, signetw As String, TotPoint As Integer)
 
Set saisie = ActiveDocument.ContentControls.Item(i)
 
Worksheets(feuille).Activate
 
Dim signet As String
Dim Libel As String
 
 
 
'recherche de la saisie (saisie - Item(1)) dans la feuille excel
Set Plage = Range("A2:A9")
For Each Ligne In Plage
    If Ligne.Text = saisie.Range Then
        Libel = Range("B" & Ligne.Row)
        signet = signetw & "_libelle"
        Call RemplirSignet(signet, Libel) 'remplir le signet en appelant la fonction
 
 Libel = Range("C" & Ligne.Row)
        signet = signetw & "_point"
        Call RemplirSignet(signet, Libel) 'remplir le signet en appelant la fonction
 
        TotPoint = TotPoint + CInt(Libel)
        TraiteMarche = TotPoint
 
    End If
Next
 
 
End Function
 
Public Function RemplirSignet(A As String, B As String)
'remplir le signet A avec le texte B
 
Dim Place As Long
Place = ActiveDocument.Bookmarks(A).Range.Start
ActiveDocument.Bookmarks(A).Range.Text = B
ActiveDocument.Bookmarks.Add Name:=A, Range:=ActiveDocument.Range(Place, Place + Len(B))
 
 
 
End Function