Form Not Launching on Workbook_Open

breynolds0431

Active Member
Joined
Feb 15, 2013
Messages
303
Office Version
  1. 365
  2. 2016
Platform
  1. 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
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

Forum statistics

Threads
1,213,513
Messages
6,114,072
Members
448,546
Latest member
KH Consulting

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