breynolds0431
Active Member
- Joined
- Feb 15, 2013
- Messages
- 303
- Office Version
- 365
- 2016
- Platform
- Windows
Hi. I have the below to launch a form when the workbook is opened. It works sometimes, but not always. When it's not working, it seems like the users need to close out all excel workbooks and open the book with the form - like it's clearing out some bugs in doing so. I thought maybe it had something to do with Enable Events, so I have it set to True. But that doesn't seem to be the case. Is there an apparent issue in the below code that I'm missing? Thanks for your time!
VBA Code:
Option Explicit
Private Sub Workbook_Open()
Sheets("-").Activate
wksProject.Visible = xlSheetVeryHidden
ThisWorkbook.Sheets("ProvLook").Visible = False
'Will run STAR update
With Application
.ScreenUpdating = False
.DisplayAlerts = False
.EnableEvents = True
End With
On Error GoTo FailedUpdate
ThisWorkbook.Sheets("ProvLook").Visible = True
wksProvLook.Select
Range("A2").CurrentRegion.Select
Selection.ClearContents
Workbooks.Open Filename:= _
"T:\*Full Path Removed*\TMFileData.xlsx", ReadOnly:=True
Columns("A:H").Select
Selection.Copy
ThisWorkbook.Activate
wksProvLook.Activate
Range("A1").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Application.Goto Reference:="Updated"
ActiveCell.FormulaR1C1 = "=NOW()"
Range("Updated").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("A2").Select
Workbooks("TMFileData.xlsx").Close savechanges:=False
ThisWorkbook.Sheets("ProvLook").Visible = False
On Error GoTo 0
frmNewProject.Show
With Application
.ScreenUpdating = True
.DisplayAlerts = True
End With
Done:
Exit Sub
FailedUpdate:
frmNewProject.Show
With Application
.ScreenUpdating = True
.DisplayAlerts = True
End With
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
wksProject.Visible = xlSheetVeryHidden
End Sub