Hello everybody,
"Invalid future reference automation error, or reference to an uncompiled type"
My code opens a workbook that when opened it increments the value of cell "A2" by +1.
So far it worked very well, but this morning it doesn't work anymore.
Maybe something is poorly defined in my code that is causing the bug.
The code stops on the line :
Sheets("Feuil1").Range("Counter") = Sheets("Feuil1").Range("Counter") + 1
Do you have an idea please??
Master workbook code
"Invalid future reference automation error, or reference to an uncompiled type"
My code opens a workbook that when opened it increments the value of cell "A2" by +1.
So far it worked very well, but this morning it doesn't work anymore.
Maybe something is poorly defined in my code that is causing the bug.
The code stops on the line :
Sheets("Feuil1").Range("Counter") = Sheets("Feuil1").Range("Counter") + 1
Do you have an idea please??
Master workbook code
VBA Code:
Sub Generer_Num_FNC()
Dim xWb As Workbook
Dim clascompteur As String
Dim Claslauncher As String
estclasseurouvert = (Not xWb Is Nothing)
Dim Wb As Workbook
Dim ladate As Date
Dim v As Variant
Claslauncher = "P:\04-Production Besancon\Qualité\01 - Déclarer Produit Non Conforme\" & "Left(chemin, pos - 1)" & ".xlsm" 'Essai avec Left... entre guillemets
clascompteur = "P:\04-Production Besancon\Qualité\01 - Déclarer Produit Non Conforme\COMPTEUR.xlsm"
' figer l'écran
Application.ScreenUpdating = False
' 1ere étape: récupérer le nom de ce classeur
chemin = ActiveWorkbook.Name
' Déverrouiller l'onglet "Formulaire"
Workbooks(chemin).Activate
Sheets("Formulaire").Visible = True
Sheets("Formulaire").Unprotect Password:="gnt"
' vérifier si classeur "Compteur" existe
If Len(Dir(clascompteur)) = 0 Then
MsgBox "ERREUR: Le classeur Compteur n'existe pas"
Exit Sub
' Else 'MsgBox "Le classeur existe"
End If
On Error GoTo Invalid:
' Ouvrir le classeur "Compteur"
Workbooks.Open Filename:=clascompteur
ActiveWorkbook.RunAutoMacros xlAutoOpen
Workbooks("COMPTEUR.xlsm").Worksheets("Feuil1").Range("E2").Copy
Workbooks(chemin).Activate
Workbooks(chemin).Worksheets("Formulaire").Range("A4").PasteSpecial xlPasteValues
Workbooks("COMPTEUR.xlsm").Activate
Workbooks("COMPTEUR.xlsm").Close savechanges = True
Workbooks(chemin).Activate
' Insérer la date du jour dans la cellule "Date_Rédaction" & "Date_Détection"
ladate = Date
Range("Date_Rédaction") = Format(ladate, "DD.MM.YYYY") 'Pour info, "WW" renvoie numéro de semaine
Range("Date_Détection") = Format(ladate, "DD.MM.YYYY")
Sheets("Formulaire").Protect Password:="gnt"
Worksheets("Formulaire").Activate
Worksheets("Formulaire").Range("Criticité").Select
' Rafraichir l'écran
Application.ScreenUpdating = True
Exit Sub
Invalid:
MsgBox ("Une erreur est survenue, veuillez contacter Flavien")
' Retourner à l'onglet "Accueil"
Sheets("Accueil").Activate
Range("A1").Select
End Sub
VBA Code:
Private Sub Workbook_Open()
Dim i As Byte
For i = 1 To Sheets.Count
Sheets("Feuil1").Range("Counter") = Sheets("Feuil1").Range("Counter") + 1
Next i
ActiveWorkbook.Save
End Sub