Error '-2147319767 (80028029)'

Flavien

Board Regular
Joined
Jan 8, 2023
Messages
54
Office Version
  1. 365
Platform
  1. Windows
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
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
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Try adding a reference to the project (Tools - References in the VB Editor), then Debug - Compile. Then remove the reference again, and Debug- Compile again. That may resolve the issue.
 
Upvote 0
Solution
thank you , RoryA, for your reply. I'm going to try that on Monday. about the reference,
do you mean I can add any reference?
 
Upvote 0
Yes, it doesn't matter which one.
 
Upvote 0

Forum statistics

Threads
1,215,076
Messages
6,122,987
Members
449,093
Latest member
Mr Hughes

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top