Good Day Folks,
I have a very very annoying problem that is intermittent, in other words, my full code works 5 to 10 times, then it crashes with a automation error as above title. The circumstances are all the same every time, always crashing 70% into my progress bar, so I know something is wrong between 70% and 80%. Just a note: The VBA is run as a macro off another macro through a CALL. And in this code it is supposed to save and close the ARCHIVE.xlsb file (All it needs to do!). There is also multiple users using the archive file, but only 1 by 1 as I have another code handling the read-only status of the file, and as the error only happens when closing the file, I see no reason how multiple users can cause it to crash. And it works 99% percent of the time, only seldom crashes with an automation error.
My code (where it crashes)
Option Explicit
Sub exitarchive()
Dim WBnEW As Object
Dim iRet As Integer
Dim pctCompl As Single
Application.ScreenUpdating = False
Application.DisplayAlerts = False
pctCompl = 70
progress pctCompl
Windows("ARCHIVE.xlsb").Activate
Set WBnEW = ActiveWorkbook
.SAVE
.Close
End With
pctCompl = 80
progress pctCompl
Application.DisplayAlerts = True
Windows("PICKING SLIPS.xlsb").Activate
Sheets("LOOKUP").Visible = True
Sheets("LOOKUP").Select
Sheets("TEMPLATE").Visible = False
Sheets("PICKING SLIP").Visible = False
Sheets("PARTS").Visible = False
pctCompl = 90
progress pctCompl
Sheets("SCRAP FILE").Visible = False
Sheets("LISTS").Visible = True
Sheets("UPDATED ARCHIVE").Visible = False
Worksheets("BAN LIST").Visible = False
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
My other untried alternative is putting in a On Error Resume - So it loops until it gets it right. But before I do that, I am asking the experts.
Thank You
JEDEMEYER1
Bookmarks