J'utilise le fichier Macro Enabled (feuille binaire) qui contient plusieurs modules/formulaires et parfois, lorsque quelque chose ne va pas avec mon ordinateur portable et qu'excel se ferme soudainement, mes fichiers autosave ne fonctionnent pas.Erreur de fichier sauvegardée automatiquement sur fichier Excel activé par macro
je reçois cette erreur sur chaque fichier enregistré automatiquement:
Erreur d'exécution '9'
Subscript hors de portée
Ma fréquence AutoSave est de 5 minutes pour sauver le dos mais cela ne marche pas intéressant pour ce fichier.
Je ne suis même pas capable de suivre l'erreur car la seule chose qui s'ouvre sur ce fichier enregistré automatiquement est la page blanche. (C'est pourquoi d'autres erreurs d'exécution 9 questions sur SO n'ont pas répondu à ma question) Quel genre de chose serait la raison et quelle est la solution possible?
MISE À JOUR: Workbook_Open des événements que j'ai dans ce classeur
Private Sub Workbook_Open()
Application.ScreenUpdating = False
ActiveWindow.Visible = False
SplashUserForm.Show
Windows(ThisWorkbook.Name).Visible = True
Application.ScreenUpdating = True
With Sheet5
.Unprotect Password:=""
.Protect DrawingObjects:=False, Contents:=True, Scenarios:= _
False, AllowFormattingCells:=True, AllowFormattingColumns:=True, _
AllowFormattingRows:=True, AllowInsertingColumns:=True, AllowInsertingRows _
:=True, AllowInsertingHyperlinks:=True, AllowDeletingColumns:=True, _
AllowDeletingRows:=True, AllowSorting:=True, AllowFiltering:=True, _
AllowUsingPivotTables:=True, UserInterfaceOnly:=True
.EnableOutlining = True
End With
With Sheet16
.Unprotect Password:=""
.Protect DrawingObjects:=False, Contents:=True, Scenarios:= _
False, AllowFormattingCells:=True, AllowFormattingColumns:=True, _
AllowFormattingRows:=True, AllowInsertingColumns:=True, AllowInsertingRows _
:=True, AllowInsertingHyperlinks:=True, AllowDeletingColumns:=True, _
AllowDeletingRows:=True, AllowSorting:=True, AllowFiltering:=True, _
AllowUsingPivotTables:=True, UserInterfaceOnly:=True
.EnableOutlining = True
End With
End Sub
Et voici ce que mon SplashUserForm a:
Private Sub UserForm_Activate()
Application.Wait (Now + TimeValue("00:00:01"))
SplashUserForm.Label1.Caption = "Loading Data..."
SplashUserForm.Repaint
Application.Wait (Now + TimeValue("00:00:01"))
SplashUserForm.Label1.Caption = "Creating Forms..."
SplashUserForm.Repaint
Application.Wait (Now + TimeValue("00:00:01"))
SplashUserForm.Label1.Caption = "Opening..."
SplashUserForm.Repaint
Application.Wait (Now + TimeValue("00:00:01"))
Unload SplashUserForm
End Sub
Private Sub UserForm_Initialize()
HideTitleBar Me
With Me
.StartUpPosition = 0
.Left = Application.Left + (0.5 * Application.Width) - (0.5 * .Width)
.Top = Application.Top + (0.5 * Application.Height) - (0.5 * .Height)
End With
End Sub
Option Explicit
Option Private Module
Public Const GWL_STYLE = -16
Public Const WS_CAPTION = &HC00000
Public Declare Function GetWindowLong _
Lib "user32" Alias "GetWindowLongA" (_
ByVal hWnd As Long, _
ByVal nIndex As Long) As Long
Public Declare Function SetWindowLong _
Lib "user32" Alias "SetWindowLongA" (_
ByVal hWnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Public Declare Function DrawMenuBar _
Lib "user32" (_
ByVal hWnd As Long) As Long
Public Declare Function FindWindowA _
Lib "user32" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Sub HideTitleBar(frm As Object)
Dim lngWindow As Long
Dim lFrmHdl As Long
lFrmHdl = FindWindowA(vbNullString, frm.Caption)
lngWindow = GetWindowLong(lFrmHdl, GWL_STYLE)
lngWindow = lngWindow And (Not WS_CAPTION)
Call SetWindowLong(lFrmHdl, GWL_STYLE, lngWindow)
Call DrawMenuBar(lFrmHdl)
End Sub
Pouvez-vous afficher votre code de sauvegarde automatique vba? – 0m3r
Peut-être que vous devriez commencer à ajouter le premier fichier de texte dans chaque sous-fonction/fonction pour créer des pistes à propos de l'endroit où cela s'est mal passé. Douloureux mais c'est que je localise une erreur qui provoque l'écrasement d'Excel lui-même. Ensuite, ajoutez plus de journal ou placez des points d'arrêt dans cette sous-fonction/fonction qui plante. – PatricK
0m3r, je n'ai aucun code de sauvegarde automatique sur mon fichier, je parle du propre système de récupération automatique d'Excel. Celui-ci fonctionne plutôt bien avec tous les autres fichiers (quand quelque chose se passe) mais ne fonctionne pas pour celui-ci. PatricK, merci pour votre explication mais honnêtement je ne sais pas comment créer ces pistes à suivre là où ça ne va pas. Et la chose est que j'ai beaucoup de modules et de formulaires qui ne savent pas où trouver ces points d'arrêt. Et j'ai besoin d'attendre le prochain crash Excel (qui provoque AutoRecover) pour suivre cette chose et nous ne savons pas quand cela se reproduira. – Mertinc